possible structure layout bug
Stephen Kennedy
Stephen.Kennedy@havok.com
Wed Jun 9 17:22:00 GMT 2004
Normally, compilers place members from derived classes starting at
sizeof(base), but gcc breaks this rule if the class contains a simd type
and places the derived member in the padding of the base class.
Reproduced with gcc-3.3 and gcc-3.4 on debian linux x86.
See the attached case
%g++-3.4 layoutbug.cpp && a.out
__m128 size 16, align 16
Quad size 16, align 16
Base1 32 Derived1 48 Offset 32 <- offset follows sizeof(base)
Base2 32 Derived2 32 Offset 20 <- offset of derived member is inside
Base3 64 Derived3 80 Offset 64 <- sizeof(base class)
Has anybody any comments? I know layouts vary from compiler to compiler,
but this seems to be inconsistent with itself.
Stephen.
--
Stephen Kennedy stephen.kennedy@havok.com http://www.havok.com/
Game Developer Frontline Award Winner 2002 & 2003
Computer Graphics World 2003 Innovation Award Winner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: layoutbug.cpp
Type: text/x-c++src
Size: 963 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20040609/056840cd/attachment.bin>
More information about the Gcc
mailing list