[Issue 14331] Cannot cast(void*) a class with an alias this struct

2018-10-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14331

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |DUPLICATE

--- Comment #2 from RazvanN  ---


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

--


[Issue 14331] Cannot cast(void*) a class with an alias this struct

2015-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14331

Martin Nowak  changed:

   What|Removed |Added

 CC||c...@dawg.eu
Summary|Can't call `destroy()` on a |Cannot cast(void*) a class
   |class with `alias this` on  |with an alias this struct
   |a struct field  |

--- Comment #1 from Martin Nowak  ---
cat > bug.d << CODE
class Test
{
static struct S {}

S s;
alias s this;
}

void main()
{
auto p = cast(void*)(new Test);
}
CODE

dmd -c bug

bug2.d(11): Error: cannot cast expression (new Test).s of type S to void*


It is a more general problem that you cannot cast the class to void*.

--