https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100934
Bug ID: 100934 Summary: wrong code at -O3 on x86_64-linux-gnu Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zhendong.su at inf dot ethz.ch Target Milestone: --- It seems to affect all versions since GCC 8.4 (but not GCC 8.3). [583] % gcctk -v Using built-in specs. COLLECT_GCC=gcctk COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --disable-bootstrap --prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib --with-system-zlib Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20210606 (experimental) [master revision 28c62475050:a6bc26893ec:a589877a0036fc2f66b7a957859940c53efdc7c9] (GCC) [584] % [584] % gcctk -O2 small.c; ./a.out [585] % [585] % gcctk -O3 small.c [586] % ./a.out Segmentation fault [587] % [587] % cat small.c int a, b, c, d, e; int main() { int f = 0, g = 0; for (; f < 2; f++) { int h, i; for (h = 0; h < 2; h++) { b = e = g ? a % g : 0; c = d; for (i = 0; i < 1; i++) g = 0; for (; g < 2; g++) ; } } return 0; }