https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111631
Bug ID: 111631 Summary: Wrong code at -Os on x86_64-linux-gnu since r14-3217-g4d6132e5932 Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch CC: rguenth at gcc dot gnu.org Target Milestone: --- gcc at -Os produced the wrong code. Bisected to r14-3217-g4d6132e5932 Compiler explorer: https://godbolt.org/z/Yj9bq1ecs $ cat a.c int printf(const char *, ...); short a, f, i; static const int *e; short *g; long h; int main() { { unsigned j = i; a = 1; for (; a; a++) { { long b = j, d = h; int c = 0; while (d--) *(char *)b++ = c; } if (e) break; } j && (*g)--; const int **k = &e; *k = 0; } printf("%d\n", f); } $ $ gcc -O0 a.c && ./a.out 0 $ gcc -Os a.c && ./a.out Segmentation fault $ gcc -fsanitize=address,undefined a.c && ./a.out 0 $