view gcc/testsuite/g++.dg/expr/ptrmem10.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
line wrap: on
line source

/* [expr.eq] If both refer to (possibly different) members of the same union
   (12.3), they compare equal. */
// { dg-do run { target c++11 } }
// { dg-additional-options -O }

union U
{
  int i;
  int j;
};

#define SA(X) static_assert ((X),#X)
SA (&U::i == &U::j);
SA (!(&U::i != &U::j));

#define assert(X) do { if (!(X)) __builtin_abort(); } while(0)

void f (int U::*p, int U::*q)
{
  assert (p==q);
  assert (!(p!=q));
}

int main()
{
  assert (&U::i == &U::j);
  assert (!(&U::i != &U::j));
}