Summary: defined opCast disables cast(void*)this in classes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD

--- Comment #0 from Andrej Mitrovic <> 2012-08-12 
20:33:46 PDT ---
class Foo
    T opCast(T : int)() { return 1; }
    void* test() { return cast(void*)this; }

void main() { }

This is problematic, cast(void*)this is the trick used to get the address of
'this' object. &this is the address of the reference and can't be used for the
same purpose. So defining opCast for any type ends up disabling

I honestly think we should have a druntime function or some kind of compiler
intrinsic to get the equivalent of 'cast(void*)this'. That cast itself looks
too hacky to begin with.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to