NonNull template

Meta jared771 at gmail.com
Sat Apr 19 09:17:29 UTC 2025


On Saturday, 19 April 2025 at 06:05:53 UTC, Walter Bright wrote:
> On 4/18/2025 12:21 AM, Ogion wrote:
>> Isn’t `ref` essentially a non-null pointer?
>
> It's supposed to be. But you can write:
> ```d
> int* p = null;
> ref r = *p;
> ```
> and you get a null ref.

How is this possible? Shouldn't dereferencing p crash the program 
before r is initialized?


More information about the Digitalmars-d mailing list