| 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 } |
| 5 |
|
| 6 |
union U |
| 7 |
{ |
| 8 |
int i; |
| 9 |
int j; |
| 10 |
}; |
| 11 |
|
| 12 |
#define SA(X) static_assert ((X),#X) |
| 13 |
SA (&U::i == &U::j); |
| 14 |
SA (!(&U::i != &U::j)); |
| 15 |
|
| 16 |
#define assert(X) do { if (!(X)) __builtin_abort(); } while(0) |
| 17 |
|
| 18 |
void f (int U::*p, int U::*q) |
| 19 |
{ |
| 20 |
assert (p==q); |
| 21 |
assert (!(p!=q)); |
| 22 |
} |
| 23 |
|
| 24 |
int main() |
| 25 |
{ |
| 26 |
assert (&U::i == &U::j); |
| 27 |
assert (!(&U::i != &U::j)); |
| 28 |
} |