From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D2A343858C55; Mon, 26 Feb 2024 13:46:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2A343858C55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708955213; bh=vcpl5nEOqm/SOgetfGaKKWQe0d2Ln6eEdgVTBFohGqY=; h=From:To:Subject:Date:From; b=hvd3dXBuyP2wo4A3Y6AlyrOtl791jINGhjzMOtQsbzq896FSfORicXBBeLkuWWn0+ L4uO53fG/kHjRMulRt0MBOw3apnv30AT6wGWk9bRuhlUwUNI03DbaHe05ILEZWUTnE MtT3zjnjc4o8SE82v61KxQLf0UIfpbXvU7BiBDiA= From: "yves.bailly at hexagon dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114114] New: Internal compiler error on function-local conditional noexcept Date: Mon, 26 Feb 2024 13:46:52 +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: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yves.bailly at hexagon 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 attachments.created 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=3D114114 Bug ID: 114114 Summary: Internal compiler error on function-local conditional noexcept Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yves.bailly at hexagon dot com Target Milestone: --- Created attachment 57542 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D57542&action=3Dedit Preprocessed file from -save-temps Tested on: - Ubuntu 22.04 with distribution's GCC 11.4.0 - Ubuntu 22.04 with "home-build" GCC 13.2.0 - Ubuntu 23.10 with distribution's GCC 13.2.0 - Godbolt's compiler explorer with GCC x86-64 "trunk" The following code causes an internal compiler error on (1): --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--- #include enum class YesNo: bool { Yes, No }; template [[nodiscard]] constexpr bool isYes(const E e) noexcept { return e =3D=3D E::Yes; } template constexpr void test() { [[maybe_unused]] constexpr bool is_yes =3D isYes(yes_or_no); // (1) struct S { #if true // (2) constexpr S() noexcept(is_yes) { std::cout << "boo\n"; } // The following compiles fine: #else constexpr S() noexcept(yes_or_no =3D=3D YesNo::Yes) { std::cout << "boo ok\n"; } #endif }; S s; } int main() { test(); } --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--- Changing the "true" to "false" on (2) makes the code compile, link and run fine. Note: this code is accepted by Clang and MSVC. Output of gcc -v: Using built-in specs. COLLECT_GCC=3D/home/ybailly/gcc13/bin/g++ COLLECT_LTO_WRAPPER=3D/home/ybailly/gcc13/libexec/gcc/x86_64-pc-linux-gnu/1= 3.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-13.2.0/configure --prefix=3D/home/ybailly/gcc13 --enable-languages=3Dc,c++,fortran --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.0 (GCC)=20 Output of "~/gcc13/bin/g++ -o test_gcc.x -std=3Dc++20 test_gcc.cpp": test_gcc.cpp: In instantiation of =E2=80=98constexpr test()::S::S() [with Y= esNo yes_or_no =3D YesNo::Yes]=E2=80=99: test_gcc.cpp:16:19: required from =E2=80=98constexpr test()::S::S() [with= YesNo yes_or_no =3D YesNo::Yes]=E2=80=99 test_gcc.cpp:24:5: required from =E2=80=98constexpr void test() [with Yes= No yes_or_no =3D YesNo::Yes]=E2=80=99 test_gcc.cpp:31:21: required from here test_gcc.cpp:11:37: internal compiler error: Segmentation fault 11 | [[maybe_unused]] constexpr bool is_yes =3D isYes(yes_or_no); //= (1) | ^~~~~~ 0xe013bf crash_signal ../../gcc-13.2.0/gcc/toplev.cc:314 0x7f673d7e851f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x88089e hash_table, tree_node*> >::hash_entry, false, xcallocator>::find_slot_with_hash(tree_node* const&, unsigned int, insert_option) ../../gcc-13.2.0/gcc/hash-table.h:1039 0x88089e hash_map, tree_node*> >::put(tree_node* const&, tree_node* const&) ../../gcc-13.2.0/gcc/hash-map.h:170 0x88089e register_local_specialization(tree_node*, tree_node*) ../../gcc-13.2.0/gcc/cp/pt.cc:1970 0x896009 tsubst_decl ../../gcc-13.2.0/gcc/cp/pt.cc:15446 0x885904 tsubst_copy ../../gcc-13.2.0/gcc/cp/pt.cc:17417 0x886588 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*) ../../gcc-13.2.0/gcc/cp/pt.cc:21676 0x889bed maybe_instantiate_noexcept(tree_node*, int) ../../gcc-13.2.0/gcc/cp/pt.cc:26754 0x88ddb2 regenerate_decl_from_template ../../gcc-13.2.0/gcc/cp/pt.cc:26553 0x88ddb2 instantiate_body ../../gcc-13.2.0/gcc/cp/pt.cc:26865 0x88e678 instantiate_decl(tree_node*, bool, bool) ../../gcc-13.2.0/gcc/cp/pt.cc:27217 0x897f22 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../gcc-13.2.0/gcc/cp/pt.cc:19397 0x898431 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../gcc-13.2.0/gcc/cp/pt.cc:18844 0x898431 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../gcc-13.2.0/gcc/cp/pt.cc:18858 0x898265 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../gcc-13.2.0/gcc/cp/pt.cc:18844 0x898265 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../gcc-13.2.0/gcc/cp/pt.cc:19238 0x88de06 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../gcc-13.2.0/gcc/cp/pt.cc:26930 0x88de06 instantiate_body ../../gcc-13.2.0/gcc/cp/pt.cc:26930 0x88e678 instantiate_decl(tree_node*, bool, bool) ../../gcc-13.2.0/gcc/cp/pt.cc:27217 Preprocessed file attached, greatly reduced by removing - the sa= me error appears without it. Regards,=