[cfe-dev] [llvm-dev] RFC: Implementing -fno-delete-null-pointer-checks in clang

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Mon May 14 12:07:08 PDT 2018


On 5/12/2018 9:23 PM, Philip Reames via llvm-dev wrote:
> Fair warning, the following is a devil's advocate position, but it's 
> also a serious question.
>
> Given the entire point of this flag appears to be bug mitigation, why 
> not frame this as a sanitizer?  If we had a hypothetical 
> -fsanitize=dereference which tried to catch dereferenced pointers 
> derived from null, wouldn't that handle the case at hand?

It's called "-fsanitize=null": it catches stuff like "x[3]" where x is 
null. It's not quite complete; we don't check for arithmetic on a null 
pointer.

Yes, that would handle the situation in question, but putting implicit 
null checks all over the place is pretty expensive; I don't think most 
people would turn that on in production.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project




More information about the cfe-dev mailing list