public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111281] New: unhelpful warning output ('nonnull' argument 'v' compared to NULL)
@ 2023-09-04  5:23 f.heckenbach@fh-soft.de
  2023-09-04  5:37 ` [Bug c++/111281] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: f.heckenbach@fh-soft.de @ 2023-09-04  5:23 UTC (permalink / raw)
  To: gcc-bugs

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. ;)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-05 20:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-04  5:23 [Bug c++/111281] New: unhelpful warning output ('nonnull' argument 'v' compared to NULL) f.heckenbach@fh-soft.de
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

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).