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

            Bug ID: 67820
           Summary: Move obscure warning about null pointers into prime
                    time
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Consider this code

extern void g( char *);

void f( char * p)
{
         if (p < 0)
                 g(p);
         if (p <= 0)
                 g(p);

         if (p >= 0)
                 g(p);
         if (p > 0)
                 g(p);
}

Compiled by trunk gcc

$ ~/gcc/results/bin/gcc -c -O2 -Wall oct2a.cc
$

Wierdly, nothing said. Then compiled with more warnings

$ ~/gcc/results/bin/gcc -c -O2 -Wall -Wextra oct2a.cc
oct2a.cc: In function ‘void f(char*)’:
oct2a.cc:6:10: warning: ordered comparison of pointer with integer zero
[-Wextra]
  if (p < 0)
          ^
oct2a.cc:8:11: warning: ordered comparison of pointer with integer zero
[-Wextra]
  if (p <= 0)
           ^
oct2a.cc:11:11: warning: ordered comparison of pointer with integer zero
[-Wextra]
  if (p >= 0)
           ^
oct2a.cc:13:10: warning: ordered comparison of pointer with integer zero
[-Wextra]
  if (p > 0)
          ^
My experience is that most folks use -Wall, but only a very few 
use -Wextra, because it produces a whole lot of other obscure warnings
on production code.

I checked the source code of redhat fedora and I estimate about
200 bugs would be detected by moving only this warning from -Wextra
into -Wall.

Reply via email to