safety: null checks
Paul Backus
snarwin at gmail.com
Mon Nov 23 00:33:35 UTC 2020
On Monday, 23 November 2020 at 00:26:26 UTC, Dibyendu Majumdar
wrote:
>
> Hmm, null values are not the same as dereferncing null values.
> A null in itself is okay, but dereferencing null cannot be.
@safe code is allowed to dereference pointers, and there's no way
for the compiler to know at compile time which pointers are null
and which aren't. So, either @safe code must be forbidden from
creating null pointers in the first place, or it must be allowed
to dereference them.
Remember, @safe doesn't just mean "code that's memory safe", it
means "code that the compiler can *prove* is memory safe."
More information about the Digitalmars-d
mailing list