This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: -fdelete-null-pointer-checks
- From: Jeff Law <law at porcupine dot cygnus dot com>
- To: Eljay Love-Jensen <eljay at adobe dot com>
- Cc: "Bansidhar Deshpande" <dbansidhar at hotmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Mon, 18 Nov 2002 09:48:57 -0700
- Subject: Re: -fdelete-null-pointer-checks
- Reply-to: law at redhat dot com
In message <4.3.2.7.2.20021118074602.00b6fd08@iplan-mn.corp.adobe.com>, Eljay L
ove-Jensen writes:
>Hi Bansidhar,
>
>I think it means that paranoia "insure that dereferenced pointers are not
>NULL" testing is no longer assured by the compiler.
>
>Either you'll get NULL dereferences (a programmer's logic error), or you
>have an OS that will signal a SEGV, such as SunOS 5.8 (aka Solaris 8).
No.
-fdelete-null-pointer-checks allows the compiler to eliminate some
unnecessary tests for null pointers that occur in the source code.
Consider this source code fragment
x = *p
if (p == NULL)
abort ()
else
do_something ()
[ ... ]
We know that p can not be NULL at the if statement because if p was NULL,
then we would have received a segfault when we dereferenced it. Thus,
-fdelete-null-pointer-checks would turn that code into
x = *p
do_something
[ ... ]
jeff