https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111422
Bug ID: 111422 Summary: Wrong code at -O3 on x86_64-linux-gnu Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch Target Milestone: --- gcc at -O3 produced the wrong code. Compiler explorer: https://godbolt.org/z/3b4v478TG $ cat a.c int printf(const char *, ...); int a, b; int *c = &b; unsigned d; char e; int f=1; int i(int k, char *l) { if (k < 6) return a; l[0] = l[1] = l[k - 1] = 8; return 0; } int m(int k) { char g[11]; int h = i(k, g); return h; } int main() { for (; b < 8; b = b + 1) ; int j; int *n[8]; j = 0; for (;18446744073709551608U + m(*c) + *c + j < 2; j++){ n[j] = &f; } for (; e <= 4; e++) d = *n[0] == f; printf("%d\n", d); } $ $ gcc -O0 a.c && ./a.out 1 $ gcc -O3 a.c && ./a.out Segmentation fault $ gcc -O3 -fwrapv a.c && ./a.out Segmentation fault $ gcc -fsanitize=address,undefined a.c && ./a.out 1 $