https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90036

            Bug ID: 90036
           Summary: False positive: directive argument is null
                    [-Werror=format-overflow=]
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dilyan.palauzov at aegee dot org
  Target Milestone: ---

See https://sourceware.org/bugzilla/show_bug.cgi?id=24440:

Compiling most recent binutils (git/master - commit
b05971a652c35ed72d3c95290e18) with gcc 8.3.1 20190330 fails with:

make[4]: Entering directory '/root/binutils/binutils'
gcc -DHAVE_CONFIG_H -I. -I/git/binutils-gdb/binutils  -I.
-I/git/binutils-gdb/binutils -I../bfd -I/git/binutils-gdb/binutils/..
/bfd -I/git/binutils-gdb/binutils/../include
-DLOCALEDIR="\"/usr/local/share/locale\""
-Dbin_dummy_emulation=bin_vanilla_emulat
ion  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow
-Wstack-usage=262144 -Werror  -O2 -pipe -g -MT wrstabs.o -MD -M
P -MF .deps/wrstabs.Tpo -c -o wrstabs.o /git/binutils-gdb/binutils/wrstabs.c
/git/binutils-gdb/binutils/wrstabs.c: In function ‘stab_start_class_type’:
/git/binutils-gdb/binutils/wrstabs.c:1476:25: error: ‘%s’ directive argument is
null [-Werror=format-overflow=]
    sprintf (vtable, "~%%%s", vstring);
                         ^~
cc1: all warnings being treated as errors
make[4]: *** [Makefile:1061: wrstabs.o] Error 1

The code snippet is:
          vtable = (char *) xmalloc (strlen (vstring) + 3);                     
          sprintf (vtable, "~%%%s", vstring);                                   
          free (vstring);                                                       

Comment 1 (https://sourceware.org/bugzilla/show_bug.cgi?id=24440#c1) says:

> That doesn't make sense.  vstring must be non-null since it has been passed 
> to strlen already.

Reply via email to