This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81928] New: if(!this) optimization leads to possible errors without warnings
- From: "matthieu.brucher at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Aug 2017 19:30:00 +0000
- Subject: [Bug c++/81928] New: if(!this) optimization leads to possible errors without warnings
- Auto-submitted: auto-generated
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).