This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/50606] New: gcc fails to detect obvious use of NULL pointer
- From: "dcb314 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Oct 2011 20:30:24 +0000
- Subject: [Bug c/50606] New: gcc fails to detect obvious use of NULL pointer
- Auto-submitted: auto-generated
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.