Nick Sabalausky (Abscissa) wrote:

(Or does &someObject return the address of the *reference* to the object rather than the address of the object?...You can see just how often I do OO in D ;) )

exactly. if you want to convert object to a pointer safely, do this:

        MyObject o;
        void* p = *cast(void**)&o;

this magic construct guarantees that you won't hit `opCast()` in `MyObject` (yes, somebody *can* write weird `opCast` for `void*`! ;-).

doing just `&o` gives you the address of a variable (on a stack, or in a tls), which is, obviously, never `null`. ;-)

Reply via email to