[Bug tree-optimization/105864] storing nullptr_t to memory should not generate any instructions

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 6 20:19:59 GMT 2022


--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Ivan Sorokin from comment #0)
> Currently storing a nullptr_t to memory causes 0 to be written to that
> memory. As there is no way to read this value back without invoking
> undefined behavior I believe GCC can omit storing it.

You can use that value to store 0 to another pointer type, and you can pass it
to a printf-style varargs function (which is passed as (void*)0). Both of those
could be made to store 0 as needed, but maybe it simplifies things to store it
early and then the later uses are just bitwise copies of the zero value.

More information about the Gcc-bugs mailing list