https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111739
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The code is undefined for alias reasons: union { int f; short g } h; *j = &h; ... a = n(h.f++); *j = 0; ... for (; i < 2; i++) d = k(h.g || 0, 59376); short *b = &h; *b ^= e; printf("%d\n", h); ``` In the case of profiling, we are able to optimize away the short load from h in: *b ^= e; and point it back to the store from `h.f++` and miss the store via *j. Once you add -fno-strict-aliasing the testcase starts to work.