#ifdef DEFINE_B struct B { unsigned long b; B &operator= (bool x) { return *this; } }; #endif struct A { void *a; }; bool operator >>= (const A &x, long &y) { typedef long __attribute__ ((may_alias)) long_a; y = *reinterpret_cast <const long_a *> (&x.a); return true; } long test(const A &x) { long a; x >>= a; return a; } issues (IMHO bogus) warning: rh448897.C:15: warning: dereferencing type-punned pointer will break strict-aliasing rules when compiled with -O2 -Wall -DDEFINE_B, but not with -O2 -Wall.
-- Summary: [4.3/4.4 Regression] Type punning warning with may_alias attribute depends on unrelated class definition Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36369