From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16931 invoked by alias); 17 Jun 2002 12:16:03 -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 16905 invoked by uid 71); 17 Jun 2002 12:16:01 -0000 Resent-Date: 17 Jun 2002 12:16:01 -0000 Resent-Message-ID: <20020617121601.16904.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jbeulich@novell.com Received: (qmail 12151 invoked by uid 61); 17 Jun 2002 12:08:00 -0000 Message-Id: <20020617120800.12148.qmail@sources.redhat.com> Date: Mon, 17 Jun 2002 05:46:00 -0000 From: jbeulich@novell.com Reply-To: jbeulich@novell.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/7054: #pragma pack handled incorrectly X-SW-Source: 2002-06/txt/msg00390.txt.bz2 List-Id: >Number: 7054 >Category: c >Synopsis: #pragma pack handled incorrectly >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Jun 17 05:16:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Jan Beulich >Release: 3.1 >Organization: >Environment: Cygwin-hosted cross compilers >Description: There are a couple of problems with #pragma pack, the most severe of which is that the sequence of #pragma pack(push, 8) #pragma pack(2) #pragma pack(pop) leaves the packing set to 2. See example below. The other issues are (a) the lack of the ability to specify a default alignment from the command line (in which case the plain #pragma pack() would have to restore that alignment rather than zero) and (b) the failure to accept #pragma pack(push) (i.e. without a new alignment, which would be assumed to be set in a subsequent #pragma pack). >How-To-Repeat: #pragma pack(push, 8) #pragma pack(2) #pragma pack(pop) struct s { unsigned u1; unsigned long long ull; unsigned u2; }; unsigned test(const struct s*ps) { return ps->u2; } >Fix: Have SET_GLOBAL_ALIGNMENT() initialize default_alignment only if alignment_stack is NULL. >Release-Note: >Audit-Trail: >Unformatted: