[Issue 16353] New: Virtual function cannot be declared and defined in the same scope.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Aug 5 02:58:52 PDT 2016


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

          Issue ID: 16353
           Summary: Virtual function cannot be declared and defined in the
                    same scope.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: maxsamukha at gmail.com

class C {
    void f();
    void f() {}
}

An overload set of two elements pointing to the same function is created. This
results in messed-up vtbl containing duplicate entries:

class D : C {
    alias f = C.f;
    override void f() {            
    }
}

1. 'alias' is required because of the abnormal overload set.
2. Only the first pointer to f is overridden in D's vtbl.

C c = new D;
c.f() // second pointer in D's vtbl is used (C.f)

Related to bug 8108.

--


More information about the Digitalmars-d-bugs mailing list