https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115758
Bug ID: 115758 Summary: Segmentation fault with -O2 Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: luwei6 at nuaa dot edu.cn Target Milestone: --- fail.c: #include <stdio.h> #include<stdint.h> int32_t a[10][10][10] = {0}; int32_t b = 0; uint64_t **c; uint64_t ***d = &c; int16_t e = 1; int16_t *f = &e; uint64_t g; uint64_t h; uint64_t l[1]; const uint64_t **m; void n() { int32_t *o = &b; if (*f) { const uint64_t *p[] = {&l[1], &l[1], &l[1], &g, &h, &g, &l[1]}; const uint64_t **q = &p[3]; int32_t r[6][3][4]; r[0][0][0] = ++*d != (m = q); } *o = **m; } int main() { int i = 1; int j = 1; int k = 1; n(); for (; i < 5; i++) for (j = 0; j < 5; j++) for (k = 0; k < 5; k++) printf("a[%d][%d][%d] = %d\n", i, j, k, a[i][j][k]); return 0; } $ gcc-trunk fail.c -w -O2 && ./a.out Segmentation fault $ gcc-trunk fail.c -w -O3 && ./a.out Segmentation fault And this is This is the link to Compiler Explorer: https://godbolt.org/z/7fjef489q