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


I jumped the gun on this draft message by accident (damn alt-s ctrl-s :)  I
did get the struct to come out to 8 once without removing the virtual
function (of which the vtbl was adding to the size) so there is still some
confusion there :)


----- Original Message -----
From: "Sean Cavanaugh" <sean@dimensionalrift.com>
To: <gcc-bugs@gcc.gnu.org>
Sent: Friday, May 05, 2000 1:21 PM
Subject: g++ 2.95.2 calculates wrong size for class


>     I have a class which when including an enum, becomes 4 bytes larger
than
> it should be.  Considering these classes represent network packets and
must
> be of exact size (especially when compared to Windows or others).
>
>     The code is in a project of which I can provide the full working
source
> for Linux (and theoretically any posix system), and is not very large and
> quite easy to setup to compile.  I tried to create a trivial repro case,
but
> those seem to work fine.  I am running Linux/Debian woody and gcc/g++
> 2.95.2.  Obviously I'm going to leave the enum in global scope for a while
> to work around it.
>
>     Here is the code fragment.  Moving enum PACKETtypes into the class
> causes the sizeof(basePacket) to return 12 instead of 8:  As an
experiement
> I also moved 'pad' to the very end of the class definition, and its offset
> was still 4.  I tried various alterations of the enum (typedef enum foo {}
> blah, etc) to no avail.
>
>
>
> enum PACKETtypes
> {
>     VIS_PACKET_NULL,
>     VIS_PACKET_GOING_DOWN,
>

</chop>


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