https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79671
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |FIXED --- Comment #30 from Jonathan Wakely <redi at gcc dot gnu.org> --- The code in comment 20 still fails even with attribute((may_alias)), so I'm not sure how the boost code can be fixed: inline void* operator new(__SIZE_TYPE__, void *p) { return p; } struct A { A (float x) : f (x) {} float f; }; static_assert(sizeof(A) == sizeof(float), ""); struct B { int x; union __attribute__((__may_alias__)) U { int a; char b[sizeof (float)]; } u; int y; }; __attribute__((noinline, noclone)) void bar (B &x, B &y) { if (x.x != 0) __builtin_abort (); if (x.y != 3) __builtin_abort (); if (y.x != 0) __builtin_abort (); if (y.y != 3) __builtin_abort (); float f; __builtin_memcpy (&f, x.u.b, sizeof (float)); if (f != 3.5f) __builtin_abort (); __builtin_memcpy (&f, y.u.b, sizeof (float)); if (f != 3.5f) __builtin_abort (); } __attribute__((noinline, noclone)) B * baz (B &x) { return &x; } __attribute__((noinline, noclone)) void foo (float x) { B b { 0, {}, 3 }, c; B *p = baz (b); new (b.u.b) A (x); c = *p; bar (*p, c); } int main () { foo (3.5f); }