https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101066
Bug ID: 101066 Summary: Wrong code after fixup_cfg3 Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: stefansf at linux dot ibm.com Target Milestone: --- Target: s390*-*-*, x86_64-*-* int a = 1, c, d, e; int *b = &a; static int g(int *h) { c = *h; return d; } static void f(int *h) { e = *h; *b = 0; g(h); } int main() { f(b); printf("%d\n", c); } Running `gcc t.c -Os && ./a.out` results in printed 1 whereas 0 is expected. This does not happen for -O[0,1,2,3] i.e. there 0 is printed. Prior fixup_cfg3 the code looks good to me and afterwards the assignment to c uses a cached/initial value of variable a which is wrong: int main () { int * b.0_1; int c.1_2; int _6; int _7; int * b.2_8; int _10; int _11; <bb 2> [local count: 1073741824]: b.0_1 = b; _6 = *b.0_1; _7 = _6; e = _7; b.2_8 = b; *b.2_8 = 0; _10 = _6; c = _10; _11 = d; c.1_2 = c; printf ("%d\n", c.1_2); return 0; } Reproducible on IBM Z as well as x86_64 using commit 831589c227c.