https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95602
Bug ID: 95602 Summary: [10/11 Regression] Wrong code w/ -O0 Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: asolokha at gmx dot com Target Milestone: --- Target: x86_64-unknown-linux-gnu Created attachment 48712 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48712&action=edit Testcase The attached (probably invalid) program segfaults if compiled w/ gcc-11.0.0-alpha20200607 snapshot (g:f08995eefbf579acfe40f0204727d5ce388e3d0a) or gcc 10.1 w/ -O0. The segfault goes away if compiled w/ higher optimization levels or setting alignment of |struct dy::oj| greater than 8. % x86_64-unknown-linux-gnu-gcc-11.0.0 -O0 -w -o bad n1rnbqt6.c % ./bad zsh: segmentation fault (core dumped) ./bad (gdb) disassemble <…> 0x0000555555554780 <+253>: test %rax,%rax 0x0000555555554783 <+256>: sete %al 0x0000555555554786 <+259>: movzbl %al,%eax 0x0000555555554789 <+262>: mov %eax,-0x10c(%rbp) 0x000055555555478f <+268>: mov -0x110(%rbp),%eax 0x0000555555554795 <+274>: cmp -0x10c(%rbp),%eax 0x000055555555479b <+280>: jne 0x555555554856 <r8+467> 0x00005555555547a1 <+286>: mov 0x1888(%rip),%rax # 0x555555556030 <mc> => 0x00005555555547a8 <+293>: movdqa (%rax),%xmm1 0x00005555555547ac <+297>: movaps %xmm1,-0x120(%rbp) <…> (gdb) info registers rax rax 0x555555556044 93824992239684 gcc 9.3 generates the following code instead: <…> 779: 48 85 c0 test %rax,%rax 77c: 0f 94 c0 sete %al 77f: 0f b6 c0 movzbl %al,%eax 782: 89 85 f4 fe ff ff mov %eax,-0x10c(%rbp) 788: 8b 85 f0 fe ff ff mov -0x110(%rbp),%eax 78e: 3b 85 f4 fe ff ff cmp -0x10c(%rbp),%eax 794: 0f 85 b3 00 00 00 jne 84d <r8+0x1ce> 79a: 48 8b 05 7f 18 00 00 mov 0x187f(%rip),%rax # 2020 <mc> 7a1: 4c 8b 30 mov (%rax),%r14 7a4: 4c 8b 78 08 mov 0x8(%rax),%r15 <…>