[Bug c++/77298] -Wnonnull-compare only emitted for code which is invoked

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Aug 19 19:42:00 GMT 2016


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.


More information about the Gcc-bugs mailing list