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 19:42:27 +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
--- Comment #8 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #6)
> Yes, that makes sense to me as an explanation of the limitation of the GCC
> implementation and a solution/workaround for it. I don't think it's
> something users unfamiliar with GCC internals think of, though. I don't
> have a sense of how much work it would be to change GCC to issue these
> warnings consistently, whether or not functions are used, but I suspect it's
> not a trivial "bug fix."
As Jakub said, making the warning consistent for "this" is not hard. You could
warn in the FE for 'this', then skip 'this' when warning in the ME.
Warning the FE is trivial:
https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/cp/typeck.c?r1=233472&r2=233471&pathrev=233472
and it will allow you to give a nicer, more specific message like Clang does.
(I think there is even a PR about the message)
Feel free to reopen this PR and refashion it with that purpose.