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

Reply via email to