Hi Paul, > On 1 Sep 2021, at 20:28, Koning, Paul via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > >> On Sep 1, 2021, at 3:08 PM, Jeff Law via Gcc-patches >> <gcc-patches@gcc.gnu.org> wrote: >> On 9/1/2021 12:57 PM, Koning, Paul wrote: >>> >>>> On Sep 1, 2021, at 1:35 PM, Jeff Law via Gcc-patches >>>> <gcc-patches@gcc.gnu.org> wrote: >>>> >>>> Generally OK. There's some C++ front-end bits that Jason ought to take a >>>> quick looksie at. Second, how does this interact with targets that allow >>>> objects at address 0? We have a few targets like that and that makes me >>>> wonder if we should be suppressing some, if not all, of these warnings for >>>> targets that turn on -fno-delete-null-pointer-checks? >>> But in C, the pointer constant 0 represents the null (invalid) pointer, not >>> the actual address zero necessarily. >>> >>> If a target supports objects at address zero, how does it represent the >>> pointer value 0 (which we usually refer to as NULL)? Is the issue simply >>> ignored? It seems to me it is in pdp11, which I would guess is one of the >>> targets for which objects at address 0 make sense. >> The issue is ignored to the best of my knowledge. > > If so, then I would think that ignoring it for this patch as well is > reasonable. If in a given target a pointer that C thinks of as NULL is in > fact a valid object pointer, then all sorts of optimizations are incorrect. > If the target really cares, it can use a different representation for the > null pointer. (Does GCC give us a way to do that?) For example, pdp11 could > use the all-ones bit pattern to represent an invalid pointer.
regardless of whether GCC supports it or not - trying to use a non-0 NULL pointer is likely to break massive amounts of code in the wild. It might, OTOH, be possible to use a non-0 special value to represent the valid 0 address-use (providing that there is somewhere in the address space you can steal that from). I wonder what things like m68k do that have vector tables at 0 … Iain