http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60816
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Adding: __builtin_printf("index1 = %d, index2 = %d.\n", iIndex - (i0or1 - 1), ( iIndex - i0or1 )); Shows the reason why it is optimized to an infinite loop: index1 = 1000, index2 = 999. You are accessing one outside the bounds of the array.