Comment #1 by witold.baryluk+d — 2007-12-22T11:35:37Z
Compiled aggainst gcc-4.1-20071105 (bsd port gdc-0.24_3).
Comment #2 by dvdfrdmn — 2008-04-19T12:13:43Z
Created attachment 247
Test Case
Comment #3 by dvdfrdmn — 2008-04-19T12:15:26Z
Comment on attachment 247
Test Case
Please ignore this comment.
Comment #4 by braddr — 2011-06-04T00:13:48Z
This is a general front end bug, not a gdc specific bug. Recategorizing it.
Changing the attached code slightly shows that mA is what's being invoked rather than the intended mB.
class ClassX : IntyD
{
void mA() { g |= 1; }
void mB() { g |= 2; }
void mD() { g |= 4; }
}
void main()
{
ClassX x = new ClassX;
assert(g == 0);
IntyB b = test(x);
assert(g == 0);
b.mB();
printf("g = %d\n", g);
assert(g == 2);
}
Comment #5 by andrej.mitrovich — 2014-02-12T06:22:55Z
Simplified test-case:
-----
interface IA
{
void mA();
}
interface IB : IA
{
void mB();
}
interface IC : IB
{
}
interface ID : IA, IC
{
void mD();
}
extern(C) int printf(in char* format, ...);
class C : ID
{
void mA() { assert(0, "mA called"); }
void mB() { printf("mB called\n"); }
void mD() { assert(0, "mD called"); }
}
void main()
{
C c = new C;
(cast(IC)c).mB(); // ok, mB called
(cast(IB)c).mB(); // fail, mA called
}
-----
Comment #6 by k.hara.pg — 2015-07-18T12:11:06Z
(In reply to Andrej Mitrovic from comment #5)
> Simplified test-case:
The cast from C to IB cast needs to be a static cast (pointer offset can be determined at compile time).
But it's currently done by using dynamic cast, and then, because of issue 2013, the dynamic cast result is incorrect.