This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77298] -Wnonnull-compare only emitted for code which is invoked
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 19 Aug 2016 15:52:46 +0000
- Subject: [Bug c++/77298] -Wnonnull-compare only emitted for code which is invoked
- Authentication-results: sourceware.org; auth=none
- Auto-submitted: auto-generated
- References: <bug-77298-4@http.gcc.gnu.org/bugzilla/>
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;
}