extern void abort (void); __attribute__((noinline)) void foo (void *p) { long l = (long) p; if (l < 0 || l > 6) abort (); }
int main () { int i; for (i = 6; i >= 0; i--) foo ((void *) (long) i); return 0; } is miscompiled (into endless loop). First ivopts decides to use a pointer IV, going from (void *) 6 down, with (void *) ivtmp.51 != (void *) -1 as loop condition, then VRP comes in and as pointers can never wrap around, optimizes the loop condition into 1. -- Summary: [4.4 Regression] ivopts + vrp miscompilation Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39233