[Bug c/50606] New: gcc fails to detect obvious use of NULL pointer

dcb314 at hotmail dot com gcc-bugzilla@gcc.gnu.org
Mon Oct 3 20:30:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50606

             Bug #: 50606
           Summary: gcc fails to detect obvious use of NULL pointer
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dcb314@hotmail.com


I just tried the following C code on latest trunk snapshot 20111001 on
an AMD x86_64 box.

# include <stdio.h>

void f( const char * p)
{
        if (p == 0)
                printf( "Hello world %s\n", p);
}

The compiler said nothing at all, which was a bit surprising.

$ ../results/bin/gcc -g -O2 -Wall -Wextra -pedantic -c bug34.c
$

OK, gcc isn't clairvoyant, but a little bit of NULL pointer tracking
might be useful, to print out a useful warning message or two.



More information about the Gcc-bugs mailing list