https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115388
Bug ID: 115388
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: ---
This appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier.
Compiler Explorer: https://godbolt.org/z/dzbaj98PM
[515] % 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/15.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 15.0.0 20240607 (experimental) (GCC)
[516] %
[516] % gcctk -O2 small.c; ./a.out
[517] % gcctk -O3 small.c
[518] % ./a.out
Aborted
[519] % cat small.c
int printf(const char *, ...);
int a[10], b, c, d[0], h, i, j, k, l;
char e = -1, g;
volatile int f;
static void n() {
while (e >= 0)
while (1)
;
for (b = 2; b >= 0; b--) {
for (k = 0; k < 4; k++) {
if (e || i)
continue;
for (h = 0; h < 2; h++)
f;
}
for (l = 2; l >= 0; l--)
g = 0;
for (; g < 1; g++)
if (c)
d[l] = 1;
a[9] = 0;
a[b] = 1;
while (j)
printf("\n");
}
}
int main() {
n();
if (a[1] != 1)
__builtin_abort();
return 0;
}