When applying a macro, it expands to:
class index { // ... typedef int index_type[2]; const index_type& operator[](int i)const; // ... }; int k = 0; int i = (index()[k])[1];
Now the problem is (assuming that index :: operator [] is public, and this is not obvious from your code fragment), so the result of index :: operator [] is returned by reference, and you build the index () object as temporary, and therefore, assuming your index :: operator [] is implemented, as I assume you have implemented it (returning a link to a member object), the result of index :: operator [] will be invalid immediately after it returns (since the temporary is destroyed), and therefore you have undefined behavior.
source share