[Issue 2061] New: wrong vtable call with multiple interface inheritance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 30 09:42:05 PDT 2008


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

           Summary: wrong vtable call with multiple interface inheritance
           Product: D
           Version: 1.029
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: schveiguy at yahoo.com


This might be related to http://d.puremagic.com/issues/show_bug.cgi?id=1978

I added Frank and Lars to the CC in case they are interested.

Basically, I think it has to do with a class implementing two interfaces that
inherit from the same base interface.

This might be a minimal example:

extern(C) int printf(char*,...);

interface A(V)
{
    int foo();
}

interface B(K, V) : A!(V)
{
    alias A!(V).foo foo; // needed or else A isn't examined to resolve foo()
    int foo(int x);
}

interface C(K, V) : B!(K, V)
{
}

interface D(K, V) : A!(V), C!(K, V)
{
    alias C!(K, V).foo foo; // needed or else A is used to resolve foo

    int bar();
}

class E(K, V) : C!(K, V)
{
    int foo() {printf("foo\n"); return 0;}
    int foo(int x) {printf("foo(int)\n"); return 0;}
    int bar() {printf("bar\n"); return 0;}
}

void main() {
  C!(uint, uint) c = new D!(uint, uint);
  c.foo();
  c.foo(0);
  c.bar();
}

outputs:
foo
bar
bar

The following change to interface D seems to resolve the issue:
interface D(K, V) : C!(K, V), A!(V)
{
    int bar();
}

However, there might be cases where this kind of solution is not possible.


-- 



More information about the Digitalmars-d-bugs mailing list