[Bug target/89788] trunk/liboffloadmic/runtime/emulator/coi_host.cpp:175]: (error) Null pointer dereference (missed -Wnull-dereference)
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 8 19:57:25 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89788
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gcc dot gnu.org
Blocks|86172 |
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
The code is still in liboffloadmic/runtime/emulator/coi_host.cpp but I wonder
why it isn't diagnosed. Passing a null pointer of any other type but char* to
%s is diagnosed by -Wformat. Usually only with optimization, passing a null
pointer to %s is then diagnosed by -Wformat-overflow. A test case for the
latter is below.
Could something like -Wno-system-headers be somehow disablig it?
$ cat pr89788.c && gcc -O2 -S -Wall -Wextra pr89788.c
#include <dirent.h>
#include <stdio.h>
void f (const char *path)
{
DIR *p = opendir (path);
if (!p)
fprintf (stderr, "error: %s", (char*)p);
}
pr89788.c: In function ‘f’:
pr89788.c:8:5: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
8 | fprintf (stderr, "error: %s", (char*)p);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86172
[Bug 86172] [meta-bug] issues with -Wnull-dereference
More information about the Gcc-bugs
mailing list