https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91137
Bug ID: 91137 Summary: Wrong code with -O3 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vsevolod.livinskij at frtk dot ru Target Milestone: --- GCC produces wrong code with –O3. Reproducer: #include <stdio.h> long long a; unsigned b; int c[70]; int d[70][70]; int e; void f(long long *g, int p2) { *g = p2; } void fn2() { for (int j = 0; j < 70; j++) { for (int i = 0; i < 70; i++) { if (b) c[i] = 0; for (int l = 0; l < 70; l++) d[i][1] = d[l][i]; } for (int k = 0; k < 70; k++) e = c[0]; } } int main() { b = 5; for (int j = 0; j < 70; ++j) c[j] = 2075593088; fn2(); f(&a, e); printf("%lld\n", a); } Error: >$ gcc -O3 repr.c ; ./a.out 2075593088 >$ gcc -O0 repr.c ; ./a.out 0 GCC version: gcc version 10.0.0 (Rev: 273261) This error can also be reproduced with gcc version 7.3.1