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
(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.