On 10/5/18 3:53 PM, Segher Boessenkool wrote: > On Fri, Oct 05, 2018 at 03:30:47PM -0600, Jeff Law wrote: >> On 10/5/18 3:14 PM, Josef Wolf wrote: >>> >>> - If the compiler can detect such a serious problem, then it should emit a >>> warning AT COMPILE TIME. >> We don't for various reasons. Frankly, I think we should as well, but I >> lost that battle. > > There is -Wnull-dereference. Yea, but our implementation is so lame that it's effectively useless. It only warns out of the front-end and only does so for an explicit *0 that can be seen without any constant propagation or path isolation. > > If you want the compiler to warn every time there *could* be a null > dereference, well, how many false positives will that be? ;-) It's really not bad if you do it late and focus just on whether or not you can see a NULL pointer flowing into a dereference. I'd certainly agree that it'd be too noisy to warn if you had a random pointer of unknown value that gets dereferenced. It could be zero and warning for all those would be useless in practice. jeff