What's the D equivalence?

Nick Treleaven nick at geany.org
Sat Mar 6 12:15:16 UTC 2021


On Saturday, 6 March 2021 at 11:52:41 UTC, Imperatorn wrote:
> On Saturday, 6 March 2021 at 11:48:37 UTC, Nick Treleaven wrote:
>> 	f(*p); // at least if p is accidentally null, it will crash 
>> here, right? nope
>> }
>>
>> This could be fixed by checking for null in @safe code when 
>> dereferencing a pointer passed to a `ref` parameter. But that 
>> doesn't fix the unsafety of the sowChaos example (although at 
>> least that isn't so confusing).
>
> To summarize, am I safe if I always null check? 🤔

How do you ensure every pointer dereference is guarded by a null 
check? I think you would need a tool to ensure that (or insert 
the checks for you).


More information about the Digitalmars-d mailing list