public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "stsp at users dot sourceforge.net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/53760] New: attribute packed doesn't pack inner structs
Date: Sun, 24 Jun 2012 14:19:00 -0000	[thread overview]
Message-ID: <bug-53760-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2012-06-24 14:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-24 14:19 stsp at users dot sourceforge.net [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-53760-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).