cast(size_t)&c != 0, but c is null

Dicebot m.strashun at gmail.com
Tue May 14 05:24:16 PDT 2013


On Tuesday, 14 May 2013 at 12:18:20 UTC, simendsjo wrote:
> Very newbie question coming up :)
>
> How does D mark null values for classes?
> `c is null` returns true, but `&c` isn't 0.
> So how does D know `c is null`?
>
> class C {}
> C c;
> assert(c is null);
> assert(cast(size_t)&c == 0); // fails.

"&c" is address of reference, no class instance. I don't know if 
there is a way to get a pointer to class instance in D but I am 
not aware of one.


More information about the Digitalmars-d-learn mailing list