While debugging a test failure in the flint library (https://github.com/flintlib/flint/issues/2029), we seem to have discovered a miscompilation. Fredrik Johansson was able to come up with a minimal reproducer. This may be a duplicate of bug 47048, but having more reproducible test cases never hurts. $ gcc-15 -O2 -Wall -Wextra main.c $ ./a.out 6 4 1 $ gcc-15 -O2 -fgraphite-identity -Wall -Wextra main.c $ ./a.out 3 2 1 $ cat main.c #include <stdio.h> void shift(long * c, long n) { long i, j; if (n <= 62) { for (i = n - 2; i >= 0; i--) for (j = i; j < n - 1; j++) c[j] += c[j + 1]; } } int main(void) { long c[3]; volatile long n = 3; c[0] = 3; c[1] = 2; c[2] = 1; shift(c, n); printf("%ld %ld %ld\n", c[0], c[1], c[2]); }
Confirmed. - Code from GCC 6 - 10 outputs "6 4 1" correctly. - Code from GCC 11 - 14 outputs "3 2 1". - Code from GCC 5 crashes with SIGFPE.
GCC 11 branch is being closed.
r11-3917-g28290cb50c7dbf