Disallow null references in safe code?

deadalnix deadalnix at gmail.com
Sun Feb 2 13:23:30 PST 2014


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.


More information about the Digitalmars-d mailing list