Bug 13392 – class + alias this + cast(void*) == overzealous cast
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2014-08-28T10:53:28Z
Last change time
2018-11-29T00:06:19Z
Keywords
wrong-code
Assigned to
No Owner
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2014-08-28T10:53:28Z
Given a class with alias this that produces another class, then "cast(void*)" will call the alias this, and try to do a cast on the alias this'ed class. I think this is wrong, since, by definition, both classes are equally good candidates for the cast, so the alias this should not happen.
//----
void foo(T)(T t)
{
void* p = cast(void*) t; //Callas alias this
}
class A {
}
class B {
alias a this;
@property A a(){assert(0);} //Here
}
void main()
{
foo(B.init);
}
//----
--- killed by signal 11
//----
I think this is actually a duplicate of 6777, all casting is disabled on the class when an alias this is present.
*** This issue has been marked as a duplicate of issue 6777 ***
Comment #3 by ag0aep6g — 2018-11-26T20:13:24Z
Issue 6777 has been fixed, but this still segfaults. Reopening.
Comment #4 by razvan.nitu1305 — 2018-11-27T09:38:48Z