This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32016] sizeof(class) always a multiple of 4 on 32 bit machine
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 May 2007 21:25:01 -0000
- Subject: [Bug c++/32016] sizeof(class) always a multiple of 4 on 32 bit machine
- References: <bug-32016-9370@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from pinskia at gcc dot gnu dot org 2007-05-21 22:24 -------
(In reply to comment #2)
> To beat a dead horse again, the data members are suitably aligned in
> Microsoft's struct. For the GNU folk to say the extra padding is for data
> alignment or is an ABI issue is misleading at best. It's only an alignment/ABI
> issue if the compiler makes it so by generating code that accesses the structs
> as if they contained ints, probably for quick copying. But if that's the case,
> I wish they would say that.
Try:
struct a33
{
struct Char1 a1;
struct Char1 a2;
};
And see what size/offset the structs are at. Again this is an ABI issue and
you did not say what exact target you are compiling for, only arm7 which does
not help because there are many different ABIs for the arm. (like arm-elf or
arm-coff or arm-eabi).
And if you want a packed struct use the attribute packed, it also packs the
size.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32016