This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: danger: Global Null Pointer Test Elimination
- To: gcc at gcc dot gnu dot org
- Subject: Re: danger: Global Null Pointer Test Elimination
- From: Geoff Keating <geoffk at ozemail dot com dot au>
- Date: 24 Sep 1999 13:22:23 +1000
- References: <C12567F5.005457EF.00@d12mta02.de.ibm.com>
veksler@il.ibm.com writes:
> IMHO this is a dangerous optimization. Consider code written for
> systems that have no MMU, and thus accessing the NULL address is
> perfectly valid. For example, the old C64 had a CPU with a special
> memory mapped register at address 0.
Given the repeated discussions we seem to be having about this and
similar optimisations, how about we add a '-fjava-mode' switch to the
C compiler, which does this:
1. All side effects happen in the order specified by the Java standard,
which I think implies that, for instance, 'i = 0; f(i++, i++);'
calls f(0,1) with i set to 2.
2. Overflow in signed types has defined behaviour as if on a
two's-complement machine. Of course, the optimisations that try to
do something with this are probably wrong for Java anyway.
3. All memory references to static (non-automatic) data and through
pointers that might point to static data are treated as 'volatile'.
Perhaps then people will stop complaining when we add optimisations to
the C mode of the C compiler which are always valid for valid C code?
--
Geoffrey Keating <geoffk@cygnus.com>