https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65178
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Status|UNCONFIRMED |NEW Last reconfirmed| |2015-02-23 CC| |manu at gcc dot gnu.org Blocks| |24639 Ever confirmed|0 |1 --- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- A minimized testcase: void *bar(int); char * foo (void) { char *c = "bla"; char *buf; for (int a = 1;; a = 0) { for (char *s = c; *s; ++s) { } if (!a) break; buf = (char *) bar (1); } return buf; } It fails in GCC 5.0 with -O1, -O2 and -O3. I think we have several reports about this: GCC simply does not understand that the loop body is executed at least once, thus there should be no (default) entry edge for the PHI node of buf. I think it is a missed optimization also: If buf were initialized, the initial value could be dropped.