Can built-in member functions other than compilation units violate binary compatibility?

I have a lot of code in a large project that has two common types of code, some of which run in good C ++ style and were reviewed by an expert in C ++, and some do not and do not. Code that does not have much for loops and uncontrolled arrays (heaps), which consist of both read and write. Fortunately, all these heap calls are done through the class. For argument, let me call it CArray.

CArrayfully defined in the header files since its inception. It is roughly defined as follows (only with the indication of the relevant parts):

template <typename elementType> class CArray
{
    /// Most of class details I'm leaving out

public:
    inline elementType & operator[](unsigned int i)
    {
#ifdef CARRAY_BOUNDARY_DEBUGGING
        if(i >= m_numElements)
        {
            throw SomeException("CArray::operator[] going out of bounds");
        }
#endif
        return m_pArray[i];
    }

    /// also have corresponding const version of this operator[]

private:
    elementType *m_pArray;
    int m_numElements;
}

(, , , , rvalue . , , , .

: (.cpp files), CARRAY_BOUNDARY_DEBUGGING, (, / ), , (, ):

  • , , , , , rvalue refrence ( ++ 11) ++ 03? ++ 11?

  • ?

: . , non inline , 3.2 ++ 03, inline. ODR - ? ++ 03 " , ".

+3
2

, , UB. . , , , ( CArray ):

struct silly_array {
    T& operator[](int x) { /* unchecked */ }
    T& at(int x) { /* check bounds */ return (*this)[x]; }
};
+3

, . 7.1.2 (4) " , , (3.2)."

+2

All Articles