This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: sizeof with virtual inheritance
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Adrian Sandor <aditsu at yahoo dot com>, gcc-help at gcc dot gnu dot org
- Date: Tue, 27 Apr 2004 07:13:07 -0500
- Subject: Re: sizeof with virtual inheritance
- References: <loom.20040427T063657-37@post.gmane.org>
Hi Adrian,
>I would like to know why the size of class objects grows when virtual
inheritance is involved.
The structure has extra bookkeeping information to keep track.
For example, if you have multiple inheritance of:
foo : bar
baz : bar
quux : foo, baz
The memory layout of quux is going to be:
bar
foo
baz
quux
If you pass a quux to something that expects a baz, that routine would expect:
bar
baz
...it wouldn't expect a "foo" stuck in the middle.
The extra "behind the scenes" bookkeeping information is used to take care
of that situation.
I do not think that it is a "onevtable" (whatever that is) related issue.
HTH,
--Eljay