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++/77298] -Wnonnull-compare only emitted for code which is invoked


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77298

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |manu at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
This is by design. Most users do not want to get warnings for code that is not
reachable or if the thing compared against NULL has changed and become NULL
(https://gcc.gnu.org/PR69835). In your case, the whole function gets optimized
out.

This is similar to:

 if (false) {
    if (this != 0)
      return handle;
 }

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