The following code produces different output in gcc4.0.0 and MSVC++7 .NET. Additionally, I've tried 3.4.3 20050227 (Red Hat 3.4.3-22.fc3) and gcc 3.3.4 20040817 (Red Hat Linux 3.3.4-2), who all produce the same output as gcc4.0.0. I'm unsure who is right here (don't know the exact C++ standards). If gcc4 is right and MSVC++ is wrong this bug is invalid. CODE: #include <stdio.h> #define DEFSTR(name) \ typedef struct name { \ unsigned int var : 13; \ }; #pragma pack(push, 1) DEFSTR(pack1_struct) #pragma pack(pop) #pragma pack(push, 2) DEFSTR(pack2_struct) #pragma pack(pop) #pragma pack(push, 4) DEFSTR(pack4_struct) #pragma pack(pop) #pragma pack(push, 8) DEFSTR(pack8_struct) #pragma pack(pop) #pragma pack(push, 16) DEFSTR(pack16_struct) #pragma pack(pop) DEFSTR(unpacked_struct) int main( int argc, char** argv ) { printf("sizeof(pack1_struct) = %u\n", sizeof(pack1_struct) ); printf("sizeof(pack2_struct) = %u\n", sizeof(pack2_struct) ); printf("sizeof(pack4_struct) = %u\n", sizeof(pack4_struct) ); printf("sizeof(pack8_struct) = %u\n", sizeof(pack8_struct) ); printf("sizeof(pack16_struct) = %u\n", sizeof(pack16_struct) ); printf("sizeof(unpacked_struct) = %u\n", sizeof(unpacked_struct) ); return 0; } PRODUCES ON GCC: sizeof(pack1_struct) = 2 sizeof(pack2_struct) = 2 sizeof(pack4_struct) = 4 sizeof(pack8_struct) = 4 sizeof(pack16_struct) = 4 sizeof(unpacked_struct) = 4 PRODUCES ON MSVC++7: sizeof(pack1_struct) = 4 sizeof(pack2_struct) = 4 sizeof(pack4_struct) = 4 sizeof(pack8_struct) = 4 sizeof(pack16_struct) = 4 sizeof(unpacked_struct) = 4
I noticed the PCC_BITFIELD_TYPE_MATTERS setting (hint: http://www.astro.cf.ac.uk/cgi-bin/info2www?(gcc)Storage%20Layout ). I guess packing settings overrule this PCC_BITFIELD_TYPE_MATTERS setting? If it was meant to do so (and not just accidentally happened to do so), then please close this bug.
Closing then. (The link you gave is broken. A more stable link is http://gcc.gnu.org/onlinedocs/gccint/Storage-Layout.html )