https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101080
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Keywords| |wrong-code Last reconfirmed| |2021-06-16 Ever confirmed|0 |1 CC| |jamborm at gcc dot gnu.org --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. Also happens with -O3 -fno-tree-vectorize which produces Program received signal SIGSEGV, Segmentation fault. 0x00000000004003b7 in main () (gdb) disassemble Dump of assembler code for function main: 0x00000000004003a0 <+0>: movzbl 0x200c95(%rip),%eax # 0x60103c <d> 0x00000000004003a7 <+7>: cmp $0x14,%al 0x00000000004003a9 <+9>: je 0x4003da <main+58> 0x00000000004003ab <+11>: nopl 0x0(%rax,%rax,1) 0x00000000004003b0 <+16>: add $0x4,%eax 0x00000000004003b3 <+19>: cmp $0x14,%al 0x00000000004003b5 <+21>: jne 0x4003b0 <main+16> => 0x00000000004003b7 <+23>: andb $0xf8,0x186(%rip) # 0x400544 <c> 0x00000000004003be <+30>: movl $0x0,0x200c70(%rip) # 0x601038 <e> 0x00000000004003c8 <+40>: movq $0x0,0x200c5d(%rip) # 0x601030 <f> 0x00000000004003d3 <+51>: movb $0x14,0x200c62(%rip) # 0x60103c <d> 0x00000000004003da <+58>: xor %eax,%eax 0x00000000004003dc <+60>: ret simpler IL testcase (elide g) - note the inlining is critical. struct a { unsigned b : 3; } const c; char d; int e; long f; static void g(const struct a h) { for (; d != 20; d = d + 4) { int i = h.b; e = h.b; f = h.b || 0; } } int main() { g(c); } so the issue is we store to 'c' which resides in .rodata - suspect this is a dup of the pending SRA issue. -fno-tree-sra fixes it. But it's a nice testcase.