[Bug c++/81928] New: if(!this) optimization leads to possible errors without warnings
matthieu.brucher at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Aug 22 20:21:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81928
Bug ID: 81928
Summary: if(!this) optimization leads to possible errors
without warnings
Product: gcc
Version: 7.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: matthieu.brucher at gmail dot com
Target Milestone: ---
The constructs if(!this) in a method raises a warning about comparison with
NULL, as it should.
We agree that this is an undefined behavior at its worst. The issue is that the
behavior of this condition is not the same between debug and optimized where
the call is considered at compile time.
Even if there is an existing warning on this undefined behavior, this should be
an error (or a warning no matter what) as there is a different behavior between
debug and optimized (even if they both make sense).
More information about the Gcc-bugs
mailing list