This is the mail archive of the gcc-help@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]

Re: -fdelete-null-pointer-checks


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


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