From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A1AC3385840E; Fri, 12 Apr 2024 20:13:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A1AC3385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712952811; bh=t++2hb17hjR0s6jDKJWKjBWZpwFaxdmHlRHamy/XxMU=; h=From:To:Subject:Date:From; b=TwnZt3FzMFDaYugTYH/Ax4fOStaHTkA14dspW7BFcsqJOhMroROLsyyylJb7XGjW5 U8FQLfXbo04spmXnsrHPG78+LxdpjVN14vRMa+aLSAnAzuDxR+aNg0qEqHH6f4/d+b zyhzllrPt/cdHeOHlU9gzCl09AcgSTuCNfnj9vcI= From: "cuzdav at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114706] New: ICE - std::bit_cast in consteval function involving union Date: Fri, 12 Apr 2024 20:13:31 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cuzdav 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: 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=3D114706 Bug ID: 114706 Summary: ICE - std::bit_cast in consteval function involving union Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cuzdav at gmail dot com Target Milestone: --- ICE in a consteval function bit_casting an array of unions. The code isn't valid due to the union, but the compiler is not handling it properly (since gcc11...trunk). Reduced to the following program: CODE #include union U { int u; }; consteval void f() { U result[]{0, 0};=20=20=20 auto x =3D std::bit_cast(result); } int main() { f(); } LIVE: https://godbolt.org/z/Y943bc5zK OUTPUT /opt/compiler-explorer/gcc-trunk-20240412/include/c++/14.0.1/bit:94:33: internal compiler error: in native_encode_initializer, at fold-const.cc:8468 94 | return __builtin_bit_cast(_To, __from); | ^~~ 0x267826c internal_error(char const*, ...) ???:0 0xa58c63 fancy_abort(char const*, int, char const*) ???:0 0xfa0eaf native_encode_initializer(tree_node*, unsigned char*, int, int, unsigned char*) ???:0 0xacf0f0 maybe_constant_value(tree_node*, tree_node*, mce_value) ???:0 0xd3a75f store_init_value(tree_node*, tree_node*, vec**, int) ???:0 0xb474fe cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int, cp_decomp*) ???:0 0xc5c81a c_parse_file() ???:0 0xdb1489 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See for instructions.=