AaronBallman wrote:

> Needs release note.
> 
> The big thing I'm not sure about is whether we want a corresponding warning. 
> We're detecting a pattern we know has undefined behavior, so we should maybe 
> warn? CC @AaronBallman @erichkeane

This pattern is undefined behavior, but we're wanting to define the behavior in 
this one specific case. My preference is to be honest about that: add 
documentation to `clang/docs/LanguageExtensions.rst` saying that we define the 
behavior of dereferencing a null pointer constant in these specific 
circumstances (and be clear that it's UB in all other circumstances), issue a 
pedantic warning about the extension, and make sure we have enough test 
coverage to help us avoid regressing the extension in the future. Bonus points 
if the pedantic warning comes with a fixit that suggest `offsetof` (not 
`__builtin_offsetof` because that's still an extension), but I don't think it's 
strictly required (fixits that require including a header file might be 
tricky?).

https://github.com/llvm/llvm-project/pull/130734
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to