digitalmars.D.bugs - [Issue 20312] New: Multiple inheritance covariance breaks vtable
- d-bugmail puremagic.com (72/72) Oct 23 2019 https://issues.dlang.org/show_bug.cgi?id=20312
https://issues.dlang.org/show_bug.cgi?id=20312 Issue ID: 20312 Summary: Multiple inheritance covariance breaks vtable dispatch Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: Hexagonalstar64 gmail.com Interface covariance causes incorrect vtable lookups when the interfaces have multiple inheritance as illustrated by this sample code. `` interface A { int x(); } interface B : A{ int y(); } interface C : A { int z(); } class Impl : B, C{ override: int x() { return 0; } int y() { return 1; } int z() { return 2; } } interface GetA{ A get(); } interface GetB : GetA{ B get(); } interface GetC : GetA { C get(); } class ImplGet : GetB, GetC{ Impl impl; this(Impl impl){ this.impl = impl; } override Impl get(){ return impl; } } import std.stdio; void main(){ Impl impl = new Impl(); C c = impl; ImplGet implget = new ImplGet(impl); GetC getc = implget; C c2 = getc.get; writeln(c.z); // prints 2 as expected writeln(c2.z); // prints 1 ! } `` `` $ dmd --version DMD64 D Compiler v2.088.1 Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright $ dmd bug $ ./bug 2 1 `` --
Oct 23 2019