Hacker News new | ask | show | jobs
by ahoka 2586 days ago
> The compiler is legally allowed to replace the null dereference with code that sends your porn collection to your mother, and set the reference to 42.

Although no sane implementation would do this.

2 comments

No, but they may optimize out assigning to the reference at all, since assigning to it requires dereferencing a provably null pointer, which means that any future code is effectively meaningless.
They wouldn't, but they could very well come to a different sane result on a particular architecture than they implementation/architecture you're on.

And that would be perfectly compiler-legal, and your code would have one free bug.