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]

danger: Global Null Pointer Test Elimination




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.

You can argue that this optimization will be turned off for MMU-less
environments, but it will not be enough. Consider an emulator for MMU-less
system running on an MMU-able system, such as a DOS emulator on Linux. This
emulator can mmap page 0 to an actual memory region, in this case gcc will
generate invalid code. I can provide more examples to prove my point.

This optimization should not be activated for -O2 or less, and it should be
possible to turn it off for higher levels.

I did not verify it, but I hope that the optimization is not never performed for
volatile pointers.

  Michael



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