http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58984
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Ah, the reason why r199252 doesn't fix this is that esra changes o.f0 = 1; into a MEM_REF, essentially *(char *)&o = 1, because the f0 has 8 bits. So, determine_known_aggregate_parts doesn't consider the o.f0 = 1 store as bitfield access. If in the testcase int f0:8 is replaced with char f0, then it is miscompiled even at -O2, and then of course o.f0 = 1 is not a bitfield, but still, it overlaps with the bit field representative of the other bitfields. So, either the replacement code really needs to be taught about bitfields anyway (at least look not just at offset, but also size of the known value and not optimize into a constant if the access is to some bits beyond the known value extent), or the punting in determine_known_aggregate_parts would need to be much more conservative.