https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106389
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org Component|ipa |c++ --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- There's a similar rule in C and we simply don't implement that - it's a "stupid rule" given there's no good way to implement it. Well. -fno-strict-aliasing. For GCC the allowed way is to access the common initial sequence through the _union_ type. Thus union U { struct A { int i; } a; struct B { int i; float f; } b; }; union U *p; p->a.i = 1; .. = p->b.i; // OK B *b = &p->b; ... = b->i; // not OK IPA modref simply makes this issue more visible (this across function boundary). Note the C rule doesn't involve unions but consider A *a = &p->a; a->i = 1; ... = b->i; I read the C++ rule as if that were allowed as well (*a could be inside a union, who knows - the union declaration might not even be visible in the TU!). For the rule to take effect the frontend needs to mark each access that falls under the rule as to have alias-set zero.