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: veksler at il dot ibm dot com
- Subject: Re: danger: Global Null Pointer Test Elimination
- From: Roman Belenov <roman at nstl dot nnov dot ru>
- Date: Thu, 23 Sep 1999 19:36:02 +0400
- CC: gcc at gcc dot gnu dot org
- Organization: NSTL
- References: <C12567F5.005457EF.00@d12mta02.de.ibm.com>
- Reply-To: Roman Belenov <roman at nstl dot nnov dot ru>
Hello Michael,
Probably this optimization will better be turned off on any level and
can be turned on only by an explicit switch; IMHO it can break some
kernel code as well (for example, in Linux kernel page faults are
sometimes used for error-checking and this optimization can disable
some special actions that have to be done in case of errors).
viic> IMHO this is a dangerous optimization. Consider code written for systems that
viic> have no MMU, and thus accessing the NULL address is perfectly valid. For
viic> example, the old C64 had a CPU with a special memory mapped register at address
viic> 0.
viic> You can argue that this optimization will be turned off for MMU-less
viic> environments, but it will not be enough. Consider an emulator for MMU-less
viic> system running on an MMU-able system, such as a DOS emulator on Linux. This
viic> emulator can mmap page 0 to an actual memory region, in this case gcc will
viic> generate invalid code. I can provide more examples to prove my point.
viic> This optimization should not be activated for -O2 or less, and it should be
viic> possible to turn it off for higher levels.
viic> I did not verify it, but I hope that the optimization is not never performed for
viic> volatile pointers.
viic> Michael
Best regards,
Roman mailto:roman@nstl.nnov.ru