[Bug c++/81928] if(!this) optimization leads to possible errors without warnings
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Aug 24 00:03:00 GMT 2017
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
More information about the Gcc-bugs
mailing list