Bug 20312 – Multiple inheritance covariance breaks vtable dispatch

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-10-24T01:24:40Z
Last change time
2024-12-13T19:05:57Z
Assigned to
No Owner
Creator
Hexagonalstar64
Moved to GitHub: dmd#19632 →

Comments

Comment #0 by Hexagonalstar64 — 2019-10-24T01:24:40Z
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 ``
Comment #1 by robert.schadek — 2024-12-13T19:05:57Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19632 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB