public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: etiotto@ca.ibm.com To: gcc-gnats@gcc.gnu.org Subject: c/9110: Zero-length bitfields cause wider structure when -fpack-struct is specified Date: Mon, 30 Dec 2002 16:46:00 -0000 [thread overview] Message-ID: <20021231003646.27734.qmail@sources.redhat.com> (raw) >Number: 9110 >Category: c >Synopsis: Zero-length bitfields cause wider structure when -fpack-struct is specified >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Dec 30 16:46:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Ettore Tiotto >Release: gcc-3.2 >Organization: >Environment: powerpc-suse-linux >Description: When the -fpack-struct command line option is used, a zero-length bitfield of type short causes padding to the next 4-byte boundary, and makes the structure size greater than the one it has when -fpack-struct is not specified. >How-To-Repeat: Consider the following structure: struct A { int a; short :0; int b:15; }; without -fpack-struct, the structure layout is: aaaaaaaa ........ bbbbbbbb bbbbbbb. the zero-length bit-field of type short caused member b to be mapped at offset 2 from the beginning of the structure. The structure has size 4 bytes. With -fpack-struct the structure layout is: aaaaaaaa ........ ........ ........ bbbbbbbb bbbbbbb. Member b is now mapped at offset 4 and the structure occupies 6 bytes. When -fpack-struct is specified I would expect the structure to occupies 3 bytes, with no padding between members a and b: aaaaaaaa bbbbbbbb bbbbbbb. or alternativelly to have the same layout as without -fpack-struct. Whichever layout is choosen, the structure size should not be greater than 4 bytes. Note: with -fpack-struct specified, member b is mapped at offset 4 even when it is a bitfield of type char, int or long. Strange enough when member b has long long type and -fpack-struct is specified, b has offset 8. >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-12-31 0:46 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-12-30 16:46 etiotto [this message] 2003-01-03 10:56 Christian Ehrhardt
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=20021231003646.27734.qmail@sources.redhat.com \ --to=etiotto@ca.ibm.com \ --cc=gcc-gnats@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: linkBe 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).