This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: g++ 2.95.2 calculates wrong size for class


>     Here is the code fragment.  Moving enum PACKETtypes into the class
> causes the sizeof(basePacket) to return 12 instead of 8

Thanks for your bug report. Unfortunately, I cannot reproduce it: I
always get a size of 12, regardless whether the enum in the class or
not. Size 12 is also the correct size: 4 bytes for header and pad,
each, plus four bytes for the virtual method table.

If you need a structure to exactly match the layout of C, it must not
have virtual methods, base classes, access declarations
(private/protected), and some other stuff.

Regards,
Martin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]