A common way to do array bounds checking is to cast the index i to unsigned and then check
if ((unsigned)i > (unsigned)length) abort(); instead of if (i >= length || i < 0) abort(); The phrases are equivalent, but VRP doesn't know that so the bounds check is not eliminated. The problem is that this is such a common idiom that it will affect many programs. -- Summary: VRP can't see through cast to unsigned Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aph at gcc dot gnu dot org GCC host triplet: x86_64-linux-gnu OtherBugsDependingO 21855 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39870