[Bug c++/13114] [ABI] wrong class hierarchy

yanliu at ca dot ibm dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 26 16:46:00 GMT 2003


------- Additional Comments From yanliu at ca dot ibm dot com  2003-11-26 16:46 -------
>With -fabi-version=0 I get the following layout
>Class Z
>   size=8 align=4
>   base size=4 base align=4
>Z (0x402f4b00) 0 nearly-empty
>    vptridx=0u vptr=((&Z::_ZTV1Z) + 12u)
>  X (0x402f4b40) 4 empty virtual
>      vbaseoffset=-0x00000000c
>    W (0x402f4b80) 4 empty
>  Y (0x402f4bc0) 0 empty
>    W (0x402f4c00) 0 empty

>which is correct.

I don't think the above class hierarchy is correct. If X and W are at offset 4, 
it means that they share the same offset with ZZ data member " int i". I don't 
think that is intentional.

>The layout IBM's VAC++ compiler is given is also incorrect. There
>cannot be an empty struct W hanging off the end of ZZ. If you create an
>array of them, X's W at index N will have the same address as Y's W at index
>N+1.

I agree. We were trying to match with GCC's behaviour at that time. And now GCC 
3.2.2 on linuxppc still puts empty class at offset greater than the class size. 
I do notice that GCC 3.3.3 with -fabi-version=2/0, the class size has been 
increased to hold the empty base class. 





-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13114



More information about the Gcc-bugs mailing list