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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
With -O0 or -fsanitize-trap=return you get a trap. With -fsanitize=return you
get a UBsan error. With -O3 you asked the compiler to optimize the heck out of
a function with undefined behaviour, what do you expect?

Either that function is never called (in which case why would you want a wasted
ret instruction increasing the binary size?) or it's called and has undefined
behaviour, which is not going to end well with -O3.

Why would you not just fix it when you see the warning?

Reply via email to