https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100511
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |alias, missed-optimization Severity|normal |enhancement --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So this is only because sizeof (XX) == sizeof(g) . That is if you add a field to XX, it works correctly. I susepct this is due to handling int can alias the access to count. I will let someone else who understands GCC's aliasing is this is a valid thing to optimize or not.