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. If you want the compiler to warn every time there *could* be a null dereference, well, how many false positives will that be? ;-) > But when the compiler sees a *0 and it'll turn that into a trap. It > also will isolate paths to a dereference where one or more paths would > result in a *0. The isolated paths will get a trap, the normal paths > will be left alone. > > The same thing is done for division by zero. > > But again, the compiler has exposed a bug in your program. Your best > course of action is to fix your code. If you have a hard time figuring out where the trap is coming from, run your program under a debugger. Segher