Test cases for sharing virtual base vptrs 3 of 3.
Coleen Phillimore
coleen at zko.dec.com
Thu Jan 13 16:39:29 UTC 2000
/*
Test case for sharing virtual bases.
In Most_Derived, share the vptr with
Interface2 but not Interface3, since
Interface3 is indirectly inherited.
Should get:
(long)(Interface1 *)dd - (long)dd = 0
(long)(Interface2 *)dd - (long)dd = 0
(long)(Interface3 *)dd - (long)dd = 8
(long)(Concrete1 *)dd - (long)dd = 8
*/
struct Interface1 {
virtual void foo();
};
struct Interface2 : virtual Interface1 {
virtual void bar();
};
struct Interface3 : virtual Interface2 {
virtual void baz();
};
struct Concrete1 : virtual Interface3 {
virtual void foo();
int i; // important.
};
struct Most_Derived : virtual Interface1,
virtual Interface2,
virtual Concrete1 {
virtual void bar();
};
void Interface1::foo() {}
void Interface2::bar() {}
void Interface3::baz() {}
void Concrete1::foo() {}
void Most_Derived::bar() {}
extern "C" int printf(const char *,...);
#define EVAL(EXPR) printf( #EXPR " = %d\n", (EXPR) );
main()
{
Most_Derived *dd = new Most_Derived;
EVAL((long)(Interface1 *)dd - (long)dd);
EVAL((long)(Interface2 *)dd - (long)dd);
EVAL((long)(Interface3 *)dd - (long)dd);
EVAL((long)(Concrete1 *)dd - (long)dd);
}
More information about the cxx-abi-dev
mailing list