From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E7D4A38515F4; Thu, 9 Mar 2023 14:56:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7D4A38515F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678373819; bh=whgBUUqiAhIh1Pvmv7m2eIB0Aoa5nmhrmKwDxTZBmfQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jP9Gz9l7odxBHLPwiP4xvHPohAfn8uubLFQYZVR1wL6V0G+qaQ39lhxW4xggWCW4m KVssYC0inz7/mj5MF5ODjmx3cTo7IwLtco6Lhd0gtD3sW1Se1P7ase/ze8k/8g7mXE lJRZqt6etyQmMj3FcBhd2X9Y33U5S01I58xFAWOY= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109039] [12/13 Regression] Miscompilation with no_unique_address and bitfields Date: Thu, 09 Mar 2023 14:56:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: ABI, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 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=3D109039 --- Comment #2 from Jakub Jelinek --- And there doesn't even have to be any NSDMI, even struct X { short x0 : 7; short x1 : 8; X () : x0 (1), x1 (2) {} int get () { return x0 + x1; } }; struct S { [[no_unique_address]] X x; char c; S () : c (0) {} }; S s; int main () { if (s.x.x0 !=3D 1 || s.x.x1 !=3D 2 || s.c !=3D 0) __builtin_abort (); } is miscompiled since that revision. With sizeof (s) =3D=3D 2 there aren't = enough bytes to fit the 15 bits of bitfields and another byte. S::x.x0 is on x86_64 at off= set 0, low 7 bits, then S::x.x1 next 8 bits, and S::c is at offset 1, so overlapping the high 7 bits of S::x.x1.=