From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10116 invoked by alias); 15 Feb 2012 18:35:00 -0000 Received: (qmail 10042 invoked by uid 22791); 15 Feb 2012 18:34:59 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 15 Feb 2012 18:34:46 +0000 From: "ktietz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/52238] -mms-bitfields: __attribute__ ((aligned (n))) ignored for struct members Date: Wed, 15 Feb 2012 18:42:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: ktietz at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-02/txt/msg01567.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52238 Kai Tietz changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ktietz at gcc dot gnu.org --- Comment #2 from Kai Tietz 2012-02-15 18:34:40 UTC --- in stor-layout.c function place_field() it is said "We already align ms_struct fields, so don't re-align them". This isn't completely true, as desired_align isn't handled in ms_struct case. Following patch seems to solve this issue: Index: stor-layout.c =================================================================== --- stor-layout.c (revision 184262) +++ stor-layout.c (working copy) @@ -1141,15 +1141,14 @@ } /* Does this field automatically have alignment it needs by virtue - of the fields that precede it and the record's own alignment? - We already align ms_struct fields, so don't re-align them. */ - if (known_align < desired_align - && !targetm.ms_bitfield_layout_p (rli->t)) + of the fields that precede it and the record's own alignment? */ + if (known_align < desired_align) { /* No, we need to skip space before this field. Bump the cumulative size to multiple of field alignment. */ - if (DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION) + if (!targetm.ms_bitfield_layout_p (rli->t) + && DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION) warning (OPT_Wpadded, "padding struct to align %q+D", field); /* If the alignment is still within offset_align, just align @@ -1302,7 +1301,7 @@ type size!) */ HOST_WIDE_INT bitsize = tree_low_cst (DECL_SIZE (field), 1); - if (rli->remaining_in_alignment < bitsize) + if (rli->remaining_in_alignment < bitsize) /* $$$$ */ { HOST_WIDE_INT typesize = tree_low_cst (TYPE_SIZE (type), 1);