On 2/2/14, 1:23 PM, deadalnix wrote:
On Sunday, 2 February 2014 at 10:58:51 UTC, Dicebot wrote:
On Sunday, 2 February 2014 at 03:45:06 UTC, 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.

Andrei

As far as I have understood previous posts, it is even worse than that
- LLVM optimiser assumes that C semantics whatever high-level language
is.

deadalnix is that true?

It depends. For instance you can specify semantic of wrap around, so
both undefined and defined overflow exists.

In the precise case we are talking about about, that really do not make
any sense to propose any other semantic as it would prevent the
optimizer to optimize away most load.

A front-end pass could replace the dead dereference with a guard that asserts the reference is not null. More generally this is a matter that can be fixed but currently is not receiving attention by backend writers.

Andrei

Reply via email to