https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101578
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- There is no bug here: struct a { short b; long c; }; union { int d; struct a c; } e = {0505355}; In the case of normal ABI, d and c.c don't overlap as c.c is aligned to alignof(long) but with -fpack-struct they will overlap. This has nothing to do with -O3 really. -fpack-struct CHANGES THE ABI as that is documented too: https://gcc.gnu.org/onlinedocs/gcc-11.1.0/gcc/Code-Gen-Options.html#index-fpack-struct Without a value specified, pack all structure members together without holes. When a value is specified (which must be a small power of two), pack structure members according to this value, representing the maximum alignment (that is, objects with default alignment requirements larger than this are output potentially unaligned at the next fitting location. Warning: the -fpack-struct switch causes GCC to generate code that is not binary compatible with code generated without that switch. Additionally, it makes the code suboptimal. Use it to conform to a non-default application binary interface.