This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]