GCC seems to have a "feature" where it always pads the end of classes (or structs) to make the class size as reported by sizeof() be a multiple of 4 bytes when targeting a 32 bit machine.
This isn't a data alignment issue as the problematic classes contain nothing but chars. It seems to be simply arbitrary with no practical use except to provide pitfalls for programmers. It makes the code non-portable if sizeof() is used and thus makes it cumbersome to define and manipulate inter-computer messages. I've always believed I could define a class or struct that would have the size I wanted with no holes if I took data alignment into consideration. That seems to be the case with other compilers, and is the case with GCC when targeting an 8 bit machine, but alas, it doesn't work on the ARM7. I can work around this by making my messages have a size that is a multiple of 4, but it doesn't seem this should be necessary. Hopefully I'll never have to use a 64 bit machine. Just to make myself clear, this isn't a data alignment thing. There are no holes between data members. All data members are chars. The hole is at the end, and the only reason for the hole that I can figure is to make sizeof() less useful. -- Summary: sizeof(class) always a multiple of 4 on 32 bit machine Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bliss1940-bbs at yahoo dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32016