https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117426
Bug ID: 117426 Summary: Miscompile with different optimization flags Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: yunboni at smail dot nju.edu.cn Target Milestone: --- When I compiled this code with -O0/1/2, its output is 1. While with -O3, its output is 0: ```c int printf(const char *, ...); int a[6]; int b, d, i, j, l, m, n; char *c; int f[8][8][4]; int *g = &d; char p[11]; int main() { short q[6]; int k = 0; for (; k < 2; k++) { { char o[3]; int e = 53; char *h = o; c = p; while (e) *c++ = e /= 10; while (c != p) *h++ = *--c; *h++ = '\0'; n = h - o; } q[n - 2] = 1; } *g = q[1]; printf("%d\n", d); l = 0; for (; l < 10; l++) if (m) printf("index = \n"); i = 0; for (; i < 7; i++) { j = 0; for (; j < 7; j++) b = a[b]; } j = 0; for (; j < 8; j++) { l = 0; for (; l < 4; l++) b = a[b ^ f[i][j][l]]; } } ``` This bug can be reproduced by 14.1 and later versions. I've checked the code with -Wall and -Wextra. The details can be found here: https://godbolt.org/z/1a9EbfoP6