From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 08D893858C5E; Mon, 1 Apr 2024 09:40:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08D893858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711964449; bh=9/PTep7kZpDi8XkcTShx9J+0kv/bv5TtKqWrci6kreo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NeAENtBbRQQk892wPsHDGqv3mnnjV+lldM2HdaQ9trKXxMWqtusNCHGOSD4a3rAWx xG/LqFDU1D61JwTTCF66S9dWiRyuSMFbUatOgzIk0QVL0k5tWKYfeEyVifOgLLEOGW 9RIOuLoDOqyk79fV0g1yujS+L0nSnKKPOdwCgJ/E= From: "fchelnokov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114537] bit_cast does not work NSDMI of bitfields Date: Mon, 01 Apr 2024 09:40:48 +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: 14.0 X-Bugzilla-Keywords: FIXME X-Bugzilla-Severity: normal X-Bugzilla-Who: fchelnokov at gmail dot com 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: 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=3D114537 --- Comment #1 from Fedor Chelnokov --- Probably related: ``` #include struct A { int a: 7; }; static_assert( 1 =3D=3D std::bit_cast(std::bit_cast(A{1})).a ); ``` It looks valid and accepted by MSVC, but GCC prints: error: '__builtin_bit_cast' accessing uninitialized byte at offset 0 Online demo: https://gcc.godbolt.org/z/3W5onY955=