http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59320
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> --- That is simple, accessing out of bounds element is undefined behavior and the compiler may optimize based on the fact that undefined behavior does not happen. As the upper bound is not constant, no warning is emitted on it, the compiler just assumes that in a valid program nd must be < 2 before entering the loop.