News for hackers. Stuff that matters.
Re:Defensive Programming by lmm on Wednesday December 23, 2020 @10:14PM (#25524744)
If you were writing assembly that would be reliable, but in C it isn't. The compiler knows that NULL dereferences are undefined behaviour and so won't necessarily compile them into memory accesses.
Re:Defensive Programming by btrask on Thursday December 24, 2020 @04:38AM (#25526192)
Yeah, in C you need to use assertions (or simple checks) for things that might be null.

That said the compiler isn't infinitely smart (thank god) and complex null derefs will "safely" make it to runtime. (What a sad world we're in.)