This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81928] if(!this) optimization leads to possible errors without warnings


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]