GCC produces wrong code with -O3. Reproducer: #include <stdio.h> long long a; int b[96][76]; int c[81]; void d(long long *e, int p2) { *e ^= p2; } int main() { for (int f = 0; f < 80; ++f) for (int g = 0; g < 76; ++g) b[f][g] = c[f] = 9094; for (int f = 6; f <= 9; f++) for (int g = 6; g <= 75; g++) if (b[0][g]) c[f + 1] *= f + (unsigned)c[f]; printf("%d\n", c[8]); } Error: >$ gcc -O3 small.c ; ./a.out 1637288310 >$ gcc -O0 small.c ; ./a.out -2106497818 GCC version is 10.0.0 (Rev: 273743)
Confirmed, started with Michael's r255467.
Mine.
Also fixed by the patch at PR90796.
Dup. *** This bug has been marked as a duplicate of bug 90796 ***