www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7985] New: Impossible to cast interface/object reference to void* in presence of 'alias this'

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7985

           Summary: Impossible to cast interface/object reference to void*
                    in presence of 'alias this'
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: samukha voliacable.com



PDT ---
struct S
{
}

interface I
{
     property S foo();
    alias foo this;
}

class A
{
     property S foo() {  return S(); }
    alias foo this;
}

void main()
{
    A a;
    I i;    
    auto ap = cast(void*)a;
    auto ip = cast(void*)i;   
}

Error: cannot cast from S to void*

It is easy to workaround for class objects by casting the reference to Object
first. Interfaces require more voodoo.

Can we just have a .ptr property on class/interface references?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 25 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7985


Maksim Zholudev <maximzms gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |maximzms gmail.com
         Resolution|                            |DUPLICATE



PST ---
*** This issue has been marked as a duplicate of issue 6777 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2013