Bug 13985 – Wrong code when using "super" to call final interface method

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-15T13:10:00Z
Last change time
2015-06-17T21:04:08Z
Keywords
wrong-code
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2015-01-15T13:10:13Z
/////// test.d /////// interface I { void m1(); void m2(); void m3(); final void mf() { m3(); } } class C1 : I { void m1() {} void m2() {} void m3() {} } class C2 : C1 { void ml() { super.mf(); } } void main() { auto l = new C2(); l.ml(); } ////////////////////// This program throws the exception: object.Exception@src\object_.d(100): need opCmp for class test.C2
Comment #1 by verylonglogin.reg — 2015-04-02T08:54:41Z
Works fine for me on 32-bit Windows OS.
Comment #2 by dlang-bugzilla — 2015-04-02T09:29:51Z
The test is no longer reproducible after https://github.com/D-Programming-Language/dmd/pull/4427 But I don't know if this fixed the underlying problem.
Comment #3 by k.hara.pg — 2015-04-02T12:24:26Z
(In reply to Vladimir Panteleev from comment #2) > The test is no longer reproducible after > https://github.com/D-Programming-Language/dmd/pull/4427 > > But I don't know if this fixed the underlying problem. It fixes this issue. The original problem was: a final function call super.mf(); wrongly looked up instance vtbl, and it would accidentally hit to Object.opCmp (it's in the third entry of vtbl). In D, there are three cases on a member function call which don't need to look up vtbl. 1) this.BaseClassType.func(); // DotTypeExp 2) super.func(); 3) this.func(); // func is a final function Issue 14211 was an issue in the case 3, and this was an issue in the case 2. I've properly handled all cases in that pull request.
Comment #4 by k.hara.pg — 2015-04-02T12:32:23Z
Comment #5 by github-bugzilla — 2015-04-02T13:14:35Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4ebacd35d52e3838aa1e936cf6bb93f339d8e70f fix Issue 13985 - Wrong code when using "super" to call final interface method
Comment #6 by github-bugzilla — 2015-06-17T21:04:08Z
Commit pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4ebacd35d52e3838aa1e936cf6bb93f339d8e70f fix Issue 13985 - Wrong code when using "super" to call final interface method