sizeof with virtual inheritance

Adrian Sandor aditsu@yahoo.com
Fri May 7 20:50:00 GMT 2004


Eljay Love-Jensen writes:

> No, my comments were specifically about virtual inheritance.

Well, here's what you wrote:

> For example, if you have multiple inheritance of:
> foo : bar
> baz : bar
> quux : foo, baz

You probably implied it, but you didn't mention virtual inheritance, so I
thought you didn't talk about it. Nevermind :)

> Look at the memory layout of c4, which is 8 bytes:
> c4 : byte[0 ... 3]
> c4.c1 : byte[4]
> c4.pad : byte[5 ... 7]
> 
> Those [0 ... 3] four bytes for the c4 portion (alone) of c4 contains the 
> pointer for the multiple inheritance overhead.

How can I see the layout like that?
And what is the actual use of that "pointer for the multiple inheritance
overhead"? What does it point to and when and how is it used?

[removed comment about "c6.c2.c3.c1" because you replied about it]

> The padding is alignment padding.

Is it possible to disable it, especially that it's at the end of the layout?

Thanks
Adrian



More information about the Gcc-help mailing list