From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6BAA03858D20; Mon, 1 Apr 2024 13:54:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BAA03858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711979662; bh=ktE3ME4CF1VaajRRE/7SePOmfZ4N49QV2zp8jkrW+Ac=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MvNAifcMPl8cLLDTIlwTj50UKNfhkLV6+epBem/3VNH4vgKd1SgVmj+F0cGFACD3I AdtvxhG9JJ1gh4UOml5860XYIN2B/gvny2Gfwdvm2rMUkwr4ofn7h+OBqWNb+PsenR Gq559vR0Ske9+YbnC569ckgmN5Etrj/RqnQc58uA= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114537] bit_cast does not work NSDMI of bitfields Date: Mon, 01 Apr 2024 13:54:21 +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: pinskia at gcc dot gnu.org 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 #2 from Andrew Pinski --- (In reply to Fedor Chelnokov from comment #1) > Probably related: > ``` > #include >=20 > struct A { int a: 7; }; >=20 > 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 >=20 > Online demo: https://gcc.godbolt.org/z/3W5onY955 That is unrelated and gcc is actually correct there see pr 99637.=