[Bug c/52991] attribute packed broken on mingw32?

daniel.c.klauer at web dot de gcc-bugzilla@gcc.gnu.org
Sat Aug 18 03:37:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991

daniel.c.klauer at web dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.c.klauer at web dot
                   |                            |de

--- Comment #1 from daniel.c.klauer at web dot de 2012-08-18 03:37:01 UTC ---
I think I may have encountered this issue aswell. For example, given the
following example program:


#include <stdio.h>
#include <wchar.h>

struct A {
    short s;
    struct { int i; };
} __attribute__((__packed__));

struct B {
    short s;
    struct { int i; } __attribute__((__packed__));
} __attribute__((__packed__));

struct C {
    struct { int i; };
    short s;
} __attribute__((__packed__));

int main() {
    printf("sizeof(struct A) == %i\n", (int)sizeof(struct A));
    printf("sizeof(struct B) == %i\n", (int)sizeof(struct B));
    printf("sizeof(struct C) == %i\n", (int)sizeof(struct C));
    return 0;
}


with TDM-GCC's mingw32 gcc 4.6.1, all sizes are 6, and for comparison, with
Ubuntu's i686-linux-gnu gcc 4.6.3, all sizes are 6.

However, with mingw.org's gcc 4.7.0, sizeof(A) == 8. B and C still are 6, as
expected; A on the other hand apparently is not being packed, despite the
__attribute__((__packed__)).



More information about the Gcc-bugs mailing list