Bug 7144 – [CTFE] base class does not call overridden members
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-12-20T07:05:00Z
Last change time
2011-12-21T15:20:47Z
Assigned to
nobody
Creator
r.sagitario
Comments
Comment #0 by r.sagitario — 2011-12-20T07:05:44Z
module test;
class A
{
int foo() { return 0; }
int callfoo()
{
return foo();
}
}
class B : A
{
override int foo() { return 1; }
}
int test()
{
A a = new B;
return a.callfoo();
}
static assert(test() == 1);
Compiling with "dmd -c test.d" yields:
test.d(24): Error: static assert (0 == 1) is false
If you use "a.foo()" instead of "a.callfoo()", the assert succeeds.