http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59320
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #13 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #12)
> 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.
Will -fsanitize=undefined catch these? If so, perhaps the message shown before
reporting a bug should mention trying this first.