This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: proposed patch for gcse.c (delete_null_pointer_checks)
- To: "Thomas R. Truscott" <trt at cs dot duke dot edu>
- Subject: Re: proposed patch for gcse.c (delete_null_pointer_checks)
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Sat, 30 Oct 1999 23:02:21 -0600
- cc: gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <199910281544.LAA29449@curly.cs.duke.edu>you write:
> > > This patch also deduces this for small offsets such as "p[1]".
> > I'm not sure that is a wise thing to do. Dereferencing a null
> > pointer is an absolute naughty thing to do according to ANSI/ISO.
> > No other pointer value has that property that I'm aware of.
>
> The draft C9X lists additional "invalid values for dereferencing",
> and indicates there may be additional implementation-defined ones.
> It also says "Such a pointer, called a null pointer, is guaranteed
> to compare unequal to a pointer to any object or function."
> I believe it is reasonable to infer that dereferencing a
> null pointer "p" is invalid whether done with p[0] or p[1] or p->x
> since none of these can be an object or function.
I've already stated twice that from a language standpoint I agree with you.
But given the way our RTL representation works, I do not believe this
optimization is safe. For further details see my previous message to
Richard Henderson.
jeff