From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C9F563858CD1; Wed, 31 May 2023 13:34:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9F563858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685540065; bh=Ux5LImHBuU55xinahuPCv9R15KjFueER93Ml36ZMmw4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rhgx5qkKqMdVNLx0Ym291Ra6ucL2xduKlS3VtMZUxoYrWY1GOUS7JOtsovoptcnFr cE3xMN7j1JIaXicT/UDOkjbWMtncBdCsI5qe6eyTUtmdNJFQVeB94CJB56mfINUh3E Uxy2aHiAXBOLwDs4KavXeVt+7B0SFJNT8xpliu3c= From: "iains at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/110044] [10, 11, 12, 13, 14 Regression] #pragma pack(push, 1) may not force packing, while __attribute__((packed, aligned(1))) works Date: Wed, 31 May 2023 13:34:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: ABI, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: iains at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: iains at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110044 --- Comment #6 from Iain Sandoe --- I'm going to test the following (which will take some time since the hardwa= re is needed for testing releases too). The test for AGGREGATE_TYPE_P() could actually be changed to RECORD_OR_UNION_TYPE_P () - since the case that we might have an array is handled for non-empty structs (but we do need to guard the empty struct cas= e).=20 The problem seems to be we were ignoring that the field type could be packe= d or that there was a cap on the max alignment. If it works as expected then I will apply to the open branches (hopefully before 10.5 is spun). ---- diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 5b3b8b52e7e..e1c038da305 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -8209,7 +8209,8 @@ darwin_rs6000_special_round_type_align (tree type, unsigned int computed, type =3D TREE_TYPE (type); } while (AGGREGATE_TYPE_P (type)); - if (! AGGREGATE_TYPE_P (type) && type !=3D error_mark_node) + if (type !=3D error_mark_node && ! AGGREGATE_TYPE_P (type) + ! TYPE_PACKED(type) && maximum_field_alignment =3D=3D 0) align =3D MAX (align, TYPE_ALIGN (type)); return align;=