https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107833
Bug ID: 107833 Summary: wrong code at -Os and above 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: --- Compiler Explorer: https://godbolt.org/z/Tc8vbearG It appears to be a regression from 11.3. [561] % 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/13.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --disable-bootstrap --enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk --enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib --with-system-zlib Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20221123 (experimental) [master r13-4262-g1cac00d0138] (GCC) [562] % [562] % gcctk -O1 small.c; ./a.out [563] % [563] % gcctk -Os small.c [564] % ./a.out Segmentation fault [565] % [565] % cat small.c int printf(const char *, ...); int a, b[1] = {0}, c, *d = b, e, *f, g; int main() { int h = 0; for (; a < 2; a++) { int i; for (g = 0; g < 2; g++) if (a < h) { e = i % 2; c = *f; } for (h = 0; h < 3; h++) { if (d) break; i--; printf("0"); } } return 0; }