public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53760] New: attribute packed doesn't pack inner structs
@ 2012-06-24 14:19 stsp at users dot sourceforge.net
  2012-06-24 17:59 ` [Bug c/53760] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: stsp at users dot sourceforge.net @ 2012-06-24 14:19 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: stsp@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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-06-25 10:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-24 14:19 [Bug c/53760] New: attribute packed doesn't pack inner structs stsp at users dot sourceforge.net
2012-06-24 17:59 ` [Bug c/53760] " pinskia at gcc dot gnu.org
2012-06-24 18:09 ` stsp at users dot sourceforge.net
2012-06-24 18:13 ` pinskia at gcc dot gnu.org
2012-06-24 18:20 ` stsp at users dot sourceforge.net
2012-06-25  6:52 ` jakub at gcc dot gnu.org
2012-06-25  8:12 ` rguenth at gcc dot gnu.org
2012-06-25 10:07 ` ebotcazou at gcc dot gnu.org
2012-06-25 10:30 ` stsp at users dot sourceforge.net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).