https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81928
--- Comment #6 from Matthieu Brucher <matthieu.brucher at gmail dot com> --- I never said that the test alone should be banned. Please read the original message first. I said that if(!this) in the context of a method gives "unexpected" behavior (according to the standard and the difference in behavior of GCC between debug and optimized mode) and thus should give an error or at least a warning, and this is easy to catch. At least make it a warning, like clang does when it detects that a path is always true or false, some kind of way for the user to _know_ that they messed up. The warning is not complicated to do as that's what the optimizer deduces given the constraints. And yes, there is something fundamentally wrong with comparing this to nullptr according to the C++ standard and the contract GCC has in its optimizer. Or give a reason why it is valid and where the standard says it supercedes the undefined behavior and the thread discussion on why GCC added the optimization constraint. And in that case, you should probably remove the optimization as well to be consistent.