[Issue 4979] New: Implementing an interface twice results in different a reference for each interface

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Oct 2 20:58:02 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4979

           Summary: Implementing an interface twice results in different a
                    reference for each interface
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: 2korden at gmail.com


--- Comment #0 from Koroskin Denis <2korden at gmail.com> 2010-10-02 20:57:43 PDT ---
interface Foo
{
}

class Bar : Foo
{
}

class Baz : Bar, Foo
{
}

void main()
{
    Baz baz = new Baz();
    Bar bar = baz;

    Foo foo1 = bar;
    Foo foo2 = baz;

    assert(foo1 is foo2);
}


foo1 and foo2 have the same type and point to the same object yet they have
different addresses.

The test above passes for C# (http://ideone.com/xK5Mu) and C++
(http://ideone.com/MnnL8 virtual inheritance used, fails otherwise, of course).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list