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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
There are two major reasons for the forcing of -fno-delete-null-pointer-checks
by the null pointer sanitizers.
One is to avoid relying too much on UB assumptions, where the optimizers say
that something can't be NULL e.g. based on nonnull/returns_nonnull attributes
and various other cases, which can't happen in valid code, but can happen in
invalid code the sanitizers are trying to help diagnose.
And the second reason is that the sanitization itself is performed by comparing
pointers against NULL and if -fdelete-null-pointer-checks is on, the optimizers
would often optimize those away.

One way to approach this is stop enabling -fno-delete-null-pointer-checks for
the sanitizers and start by replacing all flag_delete_null_pointer_checks with
that || ubsan_null_sanitization_active, then argue about if some of those could
be reverted one by one.

Reply via email to