This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Member offsets in multiple inheritance
- From: pieniek <edek dot pienkowski at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 26 May 2011 13:27:59 +0200
- Subject: Member offsets in multiple inheritance
Hello,
I have always though, that given a pointer to an object, members are at
(this) + (member-offset). But this cannot be true for multiple
inheritance, no?
Example:
struct A {
int x,y;
}
struct B {
int a, b, c;
}
struct C : public A, public B {}
int func (B* b, B* actuallyCinstance) {
return b->b + actuallyCinstance->b;
}
How is the B::b member accessed, especially b->b when b is B? What is
the cost of that (x86_64)?
Thanks,
Edek