Bug 7985 – Impossible to cast interface/object reference to void* in presence of 'alias this'

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-25T00:48:00Z
Last change time
2013-02-05T07:53:51Z
Assigned to
nobody
Creator
samukha

Comments

Comment #0 by samukha — 2012-04-25T00:48:26Z
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?
Comment #1 by maximzms — 2013-02-05T07:53:51Z
*** This issue has been marked as a duplicate of issue 6777 ***