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 //----
Comment #1 by monarchdodra — 2014-08-28T10:54:20Z
Comment #2 by schveiguy — 2016-05-17T17:30:47Z
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
Comment #5 by github-bugzilla — 2018-11-29T00:06:16Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/6e65ca834e8bbde62d92f9e21530b6ac7a07c0f0 Fix Issue 13392 and 11294 - class + alias this + cast(void*) == overzealous cast https://github.com/dlang/dmd/commit/42c71012e75b80431e83367dcbb0a37a5fea91bb Merge pull request #9017 from RazvanN7/Issue_11294 Fix Issue 13392 and 11294 - class + alias this + cast(void*) == overzealous cast merged-on-behalf-of: Nicholas Wilson <[email protected]>