https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123061
Bug ID: 123061
Summary: wrong code at -O3 with -ffinite-loops 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/3T77KPjxb
Note:
- fails: 12.1 and later
- works: 11.4 and earlier
[673] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.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 16.0.0 20251208 (experimental) (GCC)
[674] %
[674] % gcctk -O3 small.c; ./a.out
[675] %
[675] % gcctk -O3 -ffinite-loops small.c
[676] % ./a.out
Floating point exception
[677] %
[677] % cat small.c
int a, b, c, d;
int e(int f) {
if (f)
goto L;
while (1) {
b = 1;
L:
d -= b;
if (d) {
if (2 / c )
goto L;
return 0;
}
c = f;
}
}
int main() {
int g = 3;
do {
e(g);
} while (a);
return 0;
}