This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Removal of useless null pointer checks
- To: John Vickers <John dot Vickers at PaceMicro dot com>
- Subject: Re: Removal of useless null pointer checks
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Tue, 21 Sep 1999 20:07:50 -0600
- cc: gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <37E76FD9.56F681E9@PaceMicro.com>you write:
> The machine might not have an MMU, or any other means of causing a fault.
But you've triggered undefined behavior in a hosted environment. Hmm, in
a non-hosted (aka freestanding) environment it may be reasonable to have things
at address zero.
> Some unfortunate machines require writeable memory or have I/O at
> or very near address zero.
Yes. Very near doesn't count :-) The only address that matters is zero.
This optimization will not consider (mem (plus (reg X) (const_int)) as
defining X to have a nonzero value.
However, I believe it is legitimate to reference address zero in a non-hosted
environment. So we'll need to make this optimization configurable by the
front-end. I was planning to do that anyway based on some conversations I
had with the Java folks a few months back.
> I guess this optimisation won't cause as much grief as the
> strict-aliasing stuff...
> Linux kernel traps null pointers, yes ?
You'll get an oops. Don't ask me how I know :-)
jeff