[Bug c++/107798] optimizing -O3, "for" loop condition not checked anymore

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 21 22:10:14 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107798

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> When the program accesses (*m)[4]. You involved undefined behavior. Anything
> can happen after that.

Sorry (*m)[3] . So if the compiler thinks it is undefined behavior it can
optimize it any way it wants. In this case it removes the i < 9 .


More information about the Gcc-bugs mailing list