https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111838
Bug ID: 111838 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 appears to be a recent regression. Compiler Explorer: https://godbolt.org/z/Mx76x5h5K [614] % 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/14.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 Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20231016 (experimental) (GCC) [615] % [615] % gcctk -O2 small.c; ./a.out [616] % [616] % gcctk -O3 small.c; ./a.out small.c: In function ‘main’: small.c:6:17: warning: iteration 4 invokes undefined behavior [-Waggressive-loop-optimizations] 6 | if (e ? a % e : 0) | ~~^~~ small.c:5:26: note: within this loop 5 | for (char e = -17; e < 1; e += 5) { | ~~^~~ Floating point exception [617] % [617] % cat small.c int a, b, c; volatile char d; int main() { for (; b < 1; b++) for (char e = -17; e < 1; e += 5) { if (e ? a % e : 0) d; for (c = 0; c < 1; c++) ; } return 0; }