www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16980] New: [REG2.072.0] vtable issue in slightly complex

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

          Issue ID: 16980
           Summary: [REG2.072.0] vtable issue in slightly complex scenario
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: sludwig outerproduct.org

This bug is present in 2.072.0 and 2.072.1, but not on older compiler versions.

The following code, instead of calling bar(), gets the vtable of the A
interface and calls foo(). It just happens when the unrelated template instance
(tinst) is present somewhere and if T is a template struct that calls bar()
from its destructor.

---
interface A { void foo(); }
interface B { void bar(); }
interface AB : A, B {}
class C : AB {
    void foo() { assert(false, "Never called!"); }
    void bar() {}
}

struct T() {
    AB ab;
    ~this() {
        ab.bar(); // not OK, calls foo();
    }
}

T!() tinst; // NOTE: the destructor of tinst is never run!

void main()
{
    T!() dst;
    dst.ab = new C;
    dst.ab.bar(); // OK, calls bar()
}
---

This is currently a blocker for the efforts of integrating the new revamped
vibe.d core module with the rest of the library.

--
Dec 18 2016