www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4979] New: Implementing an interface twice results in different a reference for each interface

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 puremagic.com
        ReportedBy: 2korden gmail.com


--- Comment #0 from Koroskin Denis <2korden 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: -------
Oct 02 2010