Fix ptrmem comparison for unions.
[official-gcc.git] / gcc / testsuite / g++.dg / expr / ptrmem10.C
blob71d2df858600d5e119ed17a2b2bdaade1be4ea31
1 /* [expr.eq] If both refer to (possibly different) members of the same union
2    (12.3), they compare equal. */
3 // { dg-do run { target c++11 } }
4 // { dg-additional-options -O }
6 union U
8   int i;
9   int j;
12 #define SA(X) static_assert ((X),#X)
13 SA (&U::i == &U::j);
14 SA (!(&U::i != &U::j));
16 #define assert(X) do { if (!(X)) __builtin_abort(); } while(0)
18 void f (int U::*p, int U::*q)
20   assert (p==q);
21   assert (!(p!=q));
24 int main()
26   assert (&U::i == &U::j);
27   assert (!(&U::i != &U::j));