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

Re: danger: Global Null Pointer Test Elimination


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>

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