safety: null checks

Paul Backus snarwin at gmail.com
Sun Nov 22 23:28:26 UTC 2020


On Sunday, 22 November 2020 at 23:00:25 UTC, Ola Fosheim Grostad 
wrote:
> On Sunday, 22 November 2020 at 22:36:40 UTC, Paul Backus wrote:
>> Memory safety is concerned specifically with avoiding 
>> undefined behavior. Crashing the program isn't undefined 
>> behavior, so it's allowed in @safe code.
>
> I understand what you mean, but at high optimization levels 
> dereferencing a null pointer can trigger undefined behaviour.

Then that's a bug in the compiler. A @safe D program is allowed 
to dereference null, so a spec-conformant D compiler *must* 
ensure that dereferencing null has defined behavior.


More information about the Digitalmars-d mailing list