On Sunday, 2 February 2014 at 07:54:26 UTC, Jonathan M Davis
wrote:
On Saturday, February 01, 2014 19:44:44 Andrei Alexandrescu
wrote:
On 2/1/14, 7:35 PM, deadalnix wrote:
> http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html
Whoa, thanks. So the compiler figures null pointer dereference
in C is
undefined behavior, which means the entire program could do
whatever if
that does happen.
I think that article clearly illustrates that some of Walter's
decisions in D
with regards to fully defining some stuff that C didn't define
were indeed
correct. Undefined behavior is your enemy, and clearly, it gets
even worse
when the optimizer gets involved. *shudder*
- Jonathan M Davis
What you don't seem to understand is the associated cost.
Defining integer overflow to wrap around is easy and do not cost
much. But in our case, it imply that the optimizer won't be able
to optimize away load that it can't prove won't trap. That mean
the compiler won"t be able to optimize most load.