[Bug c++/81928] if(!this) optimization leads to possible errors without warnings

matthieu.brucher at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Aug 23 11:48:00 GMT 2017


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

--- Comment #4 from Matthieu Brucher <matthieu.brucher at gmail dot com> ---
I would agree if the debug and optimized versions had the same behavior. They
do not. As such there should be a huge warning about the undefined behavior. 

And no, it's not valid code, it's an undefined behavior, you can do whatever
you want with it. Outputting an error is a better solution, even adding a
warning is.  Silently optimizing an undefined behavior away is not.


More information about the Gcc-bugs mailing list