This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81928] if(!this) optimization leads to possible errors without warnings
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 23 Aug 2017 20:27:34 +0000
- Subject: [Bug c++/81928] if(!this) optimization leads to possible errors without warnings
- Auto-submitted: auto-generated
- References: <bug-81928-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81928
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |WORKSFORME
--- Comment #18 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Matthieu Brucher from comment #15)
> Of course, if there is a warning level that already does that, my comment is
> moot (although making it a higher level warning may help).
As comment 1 already said, there is a warning about it already. Have you even
tried it before this long, rambling rant?
this.cc: In member function ‘void X::f()’:
this.cc:6:3: warning: nonnull argument ‘this’ compared to NULL
[-Wnonnull-compare]
if (!this)
^~
It's included in -Wall