SafeD doesn't prevent me from dereferencing a null reference

Yutori yutori at fedora.email
Thu Aug 18 15:37:54 UTC 2022


On Thursday, 18 August 2022 at 15:27:17 UTC, Tejas wrote:

> I believe this is a design decision, since you're not invoking 
> UB in `@safe` code. Dereferencing a `null` pointer is assumed 
> to crash your program, so it's allowed to be done in `@safe` 
> code as well, since the semantics are deterministic.

Oh, I understand it now. So I guess that @safe in D is supposed 
to prevent only UB, not all memory errors that could possibly 
happen, and since dereferencing null will always result in a page 
fault, it isn't UB.


More information about the Digitalmars-d mailing list