The enclosed program prints only "0" when compiled with -O2. It should print "0" and "1". I've also tried 3.2.2 and the error is present.
Phil. #include <stdio.h> void f(int start) { int i, end; for (i = end = start; i <= end; ++i) { printf("%d\n", i); if (i == start) end = 1; } } int main() { f(0); return 0; } -- Summary: Bad loop optimization with -O2 Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: phil at fifi dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-redhat-linux-gnu GCC host triplet: i686-redhat-linux-gnu GCC target triplet: i686-redhat-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21015