public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "f.heckenbach@fh-soft.de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111281] New: unhelpful warning output ('nonnull' argument 'v' compared to NULL) Date: Mon, 04 Sep 2023 05:23:58 +0000 [thread overview] Message-ID: <bug-111281-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111281 Bug ID: 111281 Summary: unhelpful warning output ('nonnull' argument 'v' compared to NULL) Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: f.heckenbach@fh-soft.de Target Milestone: --- % cat test.cpp #include <iostream> void f (const auto &v) { std::cout << v; } int t (); int main () { f (t); } % g++ -c -std=c++20 -Wall test.cpp test.cpp: In function 'void f(const auto:11&) [with auto:11 = int()]': test.cpp:3:36: warning: 'nonnull' argument 'v' compared to NULL [-Wnonnull-compare] 3 | void f (const auto &v) { std::cout << v; } | ~~~~~~~~~~^~~~ Of course, there is an error in the code (trying to output a function pointer), but the message given is completely useless: - There is no "nonnull" in the code. - There is no comparison (to NULL or anything else for that matter) in the code. Most importantly, the message points to an innocent function that doesn't contain the actual error. While other times (e.g. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109561) GCC likes to give pages upon pages of questionable context, here it's giving clearly too little for the message to be of any use. I guess it's hard to determine a good amount of context to give, but the following two pieces of information seem essential to me: - The actual location of the code that the message refers to. Here, it must be somewhere in the library which is often hard to read, but at least may give a clue about what's going on. But the message doesn't say where. - The source code location that ultimately causes the code to be generated (here, the line in main). Of course, in the case of template instantiations it must be tracked (but in other cases GCC does this already) and there may be several places doing the same instantiation (but giving any of them would be better than none). As it is, the message doesn't say anything relevant about the code and doesn't point to any relevant location, so when I got it in my actual code, I wouldn't even know where to start looking. (Other than, as usual, guessing one of the most recent changes, but for that we only need "something's wrong" messages. ;)
next reply other threads:[~2023-09-04 5:23 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-04 5:23 f.heckenbach@fh-soft.de [this message] 2023-09-04 5:37 ` [Bug c++/111281] " pinskia at gcc dot gnu.org 2023-09-04 5:39 ` pinskia at gcc dot gnu.org 2023-09-04 5:46 ` f.heckenbach@fh-soft.de 2023-09-05 8:36 ` f.heckenbach@fh-soft.de 2023-09-05 9:48 ` redi at gcc dot gnu.org 2023-09-05 9:50 ` redi at gcc dot gnu.org 2023-09-05 9:55 ` redi at gcc dot gnu.org 2023-09-05 20:15 ` f.heckenbach@fh-soft.de
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-111281-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).