Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As I recall, the compiler didn't know it had found undefined behaviour. An optimisation pass saw "this pointer is deferenced", and from that inferred that if execution continued, the pointer can't be null.

If the pointer can't be null, then code that only executes when it is null is dead code that can be pruned.

Voila, null check removed. And most relevantly, it didn't at any point know "this is undefined behaviour". At worst it assumed that dereferencing a null would mean it wouldn't keep executing.



It removed redundant check then, why not warn about that? gcc -Wpedantic even warns about empty statements fcol.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: