https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97152
Bug ID: 97152 Summary: Wrong code generation since commit b6ff3ddecfa Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: stefansf at linux dot ibm.com Target Milestone: --- Since commit b6ff3ddecfa the following program prints the wrong number to stdout: int a = 0, j = 0; int *b = 0; int **c = &b, **i = 0; unsigned d = 0; unsigned short e = 4; long f = 0; char g = 0, k = 99; static unsigned *dPTR = &d; void l() { for (;;) { int m = 0; for (g = 0; g == 0; g++) { unsigned short *n = &e; *c = &j; if ((*n)++ == 0) return; for (d = 3; d <= 8; d++) ; *dPTR = 0; } for (; a != 0;) for (;;) for (; f != 0;) *i = &m; } } int main() { l(); printf("%d\n", d); return d; } The inner loop always executes 1 time. The expression (*n)++ evaluates after MAX_USHORT-4 times to zero which renders the if-condition true and the function call to l returns. Prior that via *dPTR = 0 variable d gets set to zero. Thus expected is 0 but 9 is printed. Any idea what went wrong?