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


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



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