From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4D44D385841B; Sun, 30 Oct 2022 06:08:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D44D385841B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667110095; bh=aK5m7mfX/VXwzM/mpAIhZHKjaOnriDIe3ypP5S/UP4Q=; h=From:To:Subject:Date:From; b=kCNgAFJXVoyWoyEOHqCbRy8/iX6K90VP8gM+MsHmDeSKWApKjdY+fOYUSW9brptDK wMYUDOqD0yBX4WnHzzQm6392UKHjuLjylvbcHhHXKGTsFWZjpI55FD1uT3ijN0ZMb1 GS2MuZl7QpMsyFeIgCaWarS6lA/m3+sm+p/zx4g0= From: "chris-gcc-bugzilla at cybermato dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107460] New: ICE with "using enum" member passed to template function (g++ 11.x-13) Date: Sun, 30 Oct 2022 06:08:14 +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: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: chris-gcc-bugzilla at cybermato 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=3D107460 Bug ID: 107460 Summary: ICE with "using enum" member passed to template function (g++ 11.x-13) Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: chris-gcc-bugzilla at cybermato dot com Target Milestone: --- Created attachment 53793 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53793&action=3Dedit file generated by -freport-bug The following code (also attached) causes an ICE in tsubst_copy on every version of g++ that can handle "using enum", with either -std=3Dc++20 or -std=3Dgnu++20, regardless of -O0, -O1, -O2, etc.: trunk (13.0.0 20221028) (Godbolt) 12.2.0 (Godbolt) 12.1.0 (Ubuntu 22.04) 11.3.0 (Godbolt) 11.2.0 (Ubuntu 22.04) 11.1 (Ubuntu 20.04) (10.4 and earlier don't seem to support "using enum") clang 13, 14, and 15 compile it with no complaint, as does MSVC (19.33 per Godbolt, plus VS 2019 and VS 2022). If I pass 'EventCat::kEventCat_Min' to boundsCheck() instead of just 'kEventCat_Min', it compiles without error. ---------------------------------------------------------------------------= ------ void fatal [[noreturn]] (const char * msg); template ToType boundsCheck(const FromType & value, const MinType & min) { if (int(value) >=3D int(min)) { return static_cast(value); } fatal ("nope"); } enum class EventCat { kEventCat_NeverUseThis =3D 0, kUninitialized, kTesting, kEventCat_Min =3D kEventCat_NeverUseThis + 1, }; struct Event { using enum EventCat; Event(EventCat a_category, auto) : category(a_category) { boundsCheck(a_category, kEventCat_Min); // using "EventCat::kEventCat_Min" instead of just "kEventCat_Min" makes this not fa= il } EventCat category =3D EventCat::kUninitialized; }; void foo() { Event(EventCat::kTesting, 0); } ---------------------------------------------------------------------------= ------ On Ubuntu 22.04 using g++-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0: $ g++-12 -c -std=3Dc++20 g++-ice-in-tsubst_copy.cpp g++-ice-in-tsubst_copy.cpp: In instantiation of =E2=80=98Event::Event(Event= Cat, auto:1) [with auto:1 =3D int]=E2=80=99: g++-ice-in-tsubst_copy.cpp:38:32: required from here g++-ice-in-tsubst_copy.cpp:30:30: internal compiler error: in tsubst_copy, = at cp/pt.cc:16919 30 | boundsCheck(a_category, kEventCat_Min); // using "EventCat::kEventCat_Min" instead of just "kEventCat_Min" makes this not fa= il | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ 0x661b9b tsubst_copy ../../src/gcc/cp/pt.cc:16919 0x80f2ce tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, boo= l, bool) ../../src/gcc/cp/pt.cc:21399 0x81e961 tsubst_copy_and_build_call_args ../../src/gcc/cp/pt.cc:19937 0x80f8c0 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, boo= l, bool) ../../src/gcc/cp/pt.cc:20687 0x8200e8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:19491 0x821097 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:18462 0x821097 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:18504 0x820c28 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:18462 0x820c28 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:18833 0x821632 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:18462 0x821632 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:18476 0x820c28 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:18462 0x820c28 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:18833 0x81f63c tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src/gcc/cp/pt.cc:26412 0x81f63c instantiate_body ../../src/gcc/cp/pt.cc:26412 0x81ff09 instantiate_decl(tree_node*, bool, bool) ../../src/gcc/cp/pt.cc:26704 0x834bdb instantiate_pending_templates(int) ../../src/gcc/cp/pt.cc:26783 0x739197 c_parse_final_cleanups() ../../src/gcc/cp/decl2.cc:5128 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.=