https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- But we still don't want to optimize aggressively based on assumed null pointer checks, after all, that is the whole point of the null sanitization. Would static inline bool delete_null_pointer_checks_p () { return flag_delete_null_pointer_checks && (flag_sanitize & (SANITIZE_NULL | SANITIZE_NONNULL_ATTRIBUTE | SANITIZE_RETURNS_NONNULL_ATTRIBUTE)) == 0; } and replacing most of flag_delete_null_pointer_checks with delete_null_pointer_checks_p () be that bad? Then constexpr evaluation could temporarily clear flag_sanitize (it doesn't want any sanitization while doing constexpr folding).