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

            Bug ID: 71157
           Summary: -Wnull-dereference false alarm in wrong function
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at gnu dot org
  Target Milestone: ---

Created attachment 38504
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38504&action=edit
preprocessed source code for emacs/lib-src/etags.c

I discovered this when compiling bleeding-edge GNU Emacs with GCC 6.1.0 on
x86-64. For the attached file e.i, the shell command:

gcc -O2 -S -Wnull-dereference e.i

issues the diagnostics:

e.i: In function 'Forth_words':
e.i:9690:10: warning: potential null pointer dereference [-Wnull-dereference]
   while (*cp != '\0' && !c_isspace (*cp))
          ^~~
e.i:9690:10: warning: potential null pointer dereference [-Wnull-dereference]
e.i:9690:10: warning: potential null pointer dereference [-Wnull-dereference]

I see three things wrong with these diagnostics. First, line 9690 is nowhere
near the function Forth_words. Second, I see no path to line 9690 in which its
pointer CP can possibly be null. Furthermore, CP is dereferenced only twice in
line 9690, so why are there three warnings?

Reply via email to