From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AEB5E3858C52; Mon, 6 Mar 2023 10:46:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEB5E3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678099590; bh=bzc3BEHsZhxHdHdgJRlJS88q05bUFuww8vtYWa9u3xA=; h=From:To:Subject:Date:From; b=ADNTZH+deUG+l7yWXfPzYelbzW+Km9t7cK3Zs7LZrkgB+4NeHo6no9nZETbVEuudL eAyaFEJN3VVRNCGVQZ0PkAdfPDIfCmTZxJg5Kwr3NqHiGR7n3MsLWr/4RIcS9+zjPd iRQhbw52KBxhKZF+K0kSACQyZcCtrBENWEP3uWu0= From: "coillol at yandex dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109039] New: Miscompilation with no_unique_address and bitfields Date: Mon, 06 Mar 2023 10:46:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: coillol at yandex dot ru X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 109039 Summary: Miscompilation with no_unique_address and bitfields Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: coillol at yandex dot ru Target Milestone: --- g++ miscompiles the following code starting from version 12.1 (-std=3Dc++20= , any optimization mode). ``` #include struct X { short x0 : 7; short x1 : 8; X() { init(); assert(get() =3D=3D 3); } void init() { x0 =3D 1; x1 =3D 2; } int get() { return x0 + x1; } }; struct S { [[no_unique_address]] X x; char c =3D 0; }; int main() { S s; assert(s.x.get() =3D=3D 3); return 0; } ``` Program hits assertion in main when executed. Links to godbolt: https://godbolt.org/z/xG186673P (12.1), https://godbolt.org/z/MaP56rfhe (trunk).=