[Issue 19192] [ICE] [wrong-code] for some interface <- abstract class <- class hierarchies

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 28 10:54:55 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19192

Nicholas Wilson <iamthewilsonator at hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |iamthewilsonator at hotmail.co
                   |                            |m
            Summary|DMD generates invalid code  |[ICE] [wrong-code] for some
                   |for covariants for some     |interface <- abstract class
                   |interface <- abstract class |<- class hierarchies
                   |<- class hierarchies        |

--- Comment #2 from Nicholas Wilson <iamthewilsonator at hotmail.com> ---
This appears to be a missing an offset somewhere.

printf("%p", foo);       //0x7fe552a44010
printf("%p", foo.troll); //0x7fe552a44000

It fails also with LDC so the problem is likely a missed cast in the frontend.
Note that:

interface Foo
{
    Foo troll();
}

abstract class Barbee : Foo {}

class Bar : Barbee
{
    /*Bar*/ Foo troll() { return this; }
}

Works. and 

interface Foo
{
    Foo troll();
}

abstract class Barbee : Foo {}
//alias Barbee = Foo;
class Bar : Barbee
{
    Bar troll() { return this; }
}

void main()
{
    Foo foo = new Bar;
    auto troll = cast(Barbee)foo.troll; // ICE's
    assert(foo is troll);
}

ICE's

--


More information about the Digitalmars-d-bugs mailing list