https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97913
--- Comment #6 from Alexey Klimkin <alexey.klimkin at intel dot com> --- Created attachment 65252 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65252&action=edit Proposed patch: keep constant evaluation independent of null-check optimization I attached a proposed patch for PR71962 and PR97913. -fsanitize=null implicitly disables -fdelete-null-pointer-checks, but that optimization setting should not change which C++ expressions are accepted as constant expressions. The patch makes maybe_nonzero_address answer as if null-pointer-check deletion were enabled only during manifest constant evaluation. Runtime folding still honors the option, and undefined weak symbols remain conservative. The tests cover direct -fno-delete-null-pointer-checks, -fsanitize=null, runtime weak-symbol comparisons, and an undefined weak symbol. Focused before/after testing shows the constant-expression cases fail without the patch and pass with it, while the two runtime weak-symbol comparisons remain in optimized output. The patch is submitted under the DCO sign-off included in the attachment.
