From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28919 invoked by alias); 31 Dec 2002 00:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 28901 invoked by uid 71); 31 Dec 2002 00:46:00 -0000 Resent-Date: 31 Dec 2002 00:46:00 -0000 Resent-Message-ID: <20021231004600.28900.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, etiotto@ca.ibm.com Received: (qmail 27735 invoked by uid 61); 31 Dec 2002 00:36:46 -0000 Message-Id: <20021231003646.27734.qmail@sources.redhat.com> Date: Mon, 30 Dec 2002 16:46:00 -0000 From: etiotto@ca.ibm.com Reply-To: etiotto@ca.ibm.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/9110: Zero-length bitfields cause wider structure when -fpack-struct is specified X-SW-Source: 2002-12/txt/msg01449.txt.bz2 List-Id: >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: