public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/9110: Zero-length bitfields cause wider structure when -fpack-struct is specified
@ 2002-12-30 16:46 etiotto
  0 siblings, 0 replies; 2+ messages in thread
From: etiotto @ 2002-12-30 16:46 UTC (permalink / raw)
  To: gcc-gnats


>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:


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

* Re: c/9110: Zero-length bitfields cause wider structure when -fpack-struct is specified
@ 2003-01-03 10:56 Christian Ehrhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2003-01-03 10:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/9110; it has been noted by GNATS.

From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
  nobody@gcc.gnu.org, etiotto@ca.ibm.com
Cc:  
Subject: Re: c/9110: Zero-length bitfields cause wider structure when -fpack-struct is specified
Date: Fri, 3 Jan 2003 11:46:46 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9110
 Some discussion about this PR got picked up by GNATS as PR 9141 and PR 9142.
 The executive summary is:
 a) Mark probably fixed this but someone has to verify on power-pc or build
    a cross compiler.
 b) The code snipped in the test case is is wrong, field a should habe type
    char.
 


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

end of thread, other threads:[~2003-01-03 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-30 16:46 c/9110: Zero-length bitfields cause wider structure when -fpack-struct is specified etiotto
2003-01-03 10:56 Christian Ehrhardt

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).