This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: g++ 2.95.2 calculates wrong size for class
- To: sean at dimensionalrift dot com
- Subject: Re: g++ 2.95.2 calculates wrong size for class
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 5 May 2000 23:40:05 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <008701bfb6cf$8a101ae0$d69ccacf@void>
> 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