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

             Bug #: 53760
           Summary: attribute packed doesn't pack inner structs
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: s...@users.sourceforge.net


The following code:

---
#include <stdio.h>

struct A {
    char a:1;
    struct {
        char a:1;
    } __attribute__((packed)) s1;
    struct {
        char a:1;
    } __attribute__((packed)) s2;
    struct {
        char a:1;
    } __attribute__((packed)) s3;
} __attribute__((packed));

int main()
{
    printf("%lu\n", sizeof(struct A));
    return 0;
}
---

prints '4' instead of '1'.
Every bitfield seems to be occupying an entire byte.

Reply via email to