From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4A61E3858D32; Mon, 22 Jan 2024 16:53:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A61E3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705942437; bh=9wr6k9u2Xjb8Dzfgixg+iIGoq4ZWrs12fL/fH7SM9kY=; h=From:To:Subject:Date:From; b=m5CAtcUWZ13Y6NMggI2bLYsHSYBbHG/evdJhQj7wjnnxG8+THmkv5mRSr2W5kYJlQ MCwfYHSEGQ31gToZE7wO1kAoQ1spU5SmriDpgoJm0iOtGIsj0PbM37+3sb0K5wfsG1 M+zeImC5iqHuswlHPNZu6uZlFBhBD8JjPVdTxD1U= From: "hp at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113545] New: ICE in label_matches with constexpr function with switch-statement and converted (nonconstant, cast address) input Date: Mon, 22 Jan 2024 16:53:56 +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: hp 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: 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=3D113545 Bug ID: 113545 Summary: ICE in label_matches with constexpr function with switch-statement and converted (nonconstant, cast address) input Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hp at gcc dot gnu.org Target Milestone: --- For the following test-case, g++ ICEs from at least gcc-10 and forward (i.e. apparently not a regression): ``` char foo; constexpr unsigned char bar(__UINTPTR_TYPE__ baz) { switch (baz) { case 13: return 11; case 14: return 78; case 2048: return 13; default: return 42; } } __attribute__ ((__noipa__)) void xyzzy(int x) { if (x !=3D 42) __builtin_abort (); } int main() { unsigned const char c =3D bar(reinterpret_cast<__UINTPTR_TYPE__>(&foo)); xyzzy(c); } ''' Example backtrace with -std=3Dc++20 -O3: ../n.cc: In function 'int main()': ../n.cc:27:30: in 'constexpr' expansion of 'bar(((long unsigned int)(& foo)))' ../n.cc:5:3: internal compiler error: in label_matches, at cp/constexpr.cc:= 6925 5 | switch (baz) | ^~~~~~ 0x63894c label_matches /gcctop/gcc/cp/constexpr.cc:6925 0xa0bb3d cxx_eval_constant_expression /gcctop/gcc/cp/constexpr.cc:7319 0xa0d2b2 cxx_eval_statement_list /gcctop/gcc/cp/constexpr.cc:6969 0xa0d2b2 cxx_eval_constant_expression /gcctop/gcc/cp/constexpr.cc:8316 0xa1e782 cxx_eval_switch_expr /gcctop/gcc/cp/constexpr.cc:7115 0xa0cb6b cxx_eval_constant_expression /gcctop/gcc/cp/constexpr.cc:8412 0xa0aae6 cxx_eval_call_expression /gcctop/gcc/cp/constexpr.cc:3288 0xa0c2ef cxx_eval_constant_expression /gcctop/gcc/cp/constexpr.cc:7524 0xa17d9a cxx_eval_outermost_constant_expr /gcctop/gcc/cp/constexpr.cc:8822 0xa1d28f maybe_constant_value(tree_node*, tree_node*, mce_value) /gcctop/gcc/cp/constexpr.cc:9110 0xa49e40 cp_fully_fold /gcctop/gcc/cp/cp-gimplify.cc:2831 0xa49ed9 cp_fully_fold /gcctop/gcc/cp/cp-gimplify.cc:2825 0xa49ed9 cp_fully_fold_init(tree_node*) /gcctop/gcc/cp/cp-gimplify.cc:2861 0xc7a204 store_init_value(tree_node*, tree_node*, vec**, int) /gcctop/gcc/cp/typeck2.cc:926 0xa6ca32 check_initializer /gcctop/gcc/cp/decl.cc:7810 0xa941be cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int, cp_decomp*) /gcctop/gcc/cp/decl.cc:8842 0xb95477 cp_parser_init_declarator /gcctop/gcc/cp/parser.cc:23618 0xb6ac98 cp_parser_simple_declaration /gcctop/gcc/cp/parser.cc:15890 0xb8f830 cp_parser_declaration_statement /gcctop/gcc/cp/parser.cc:14926 0xb97215 cp_parser_statement /gcctop/gcc/cp/parser.cc:12882 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.=