[Bug c++/97976] Optimization relating to NULL pointer assumptions in gcc 9.1

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 26 00:20:26 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97976

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---

6.3.2.3 p3 says a null pointer compares unequal to any pointer to an object, so
that means no object can ever be at address 0 in a valid C program. If you're
not using the -fno-delete-null-pointer-checks option then GCC is perfectly
justified to assume no object is at address 0 (because the standards say that's
not possible).

The footnote on 6.5.3.2 clarifies that a null pointer is not a valid operand
for the unary * operator. 

For C++, [basic.compound] says a pointer can point to an object or be null, not
both.


More information about the Gcc-bugs mailing list