From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6641F3886C65; Thu, 8 Jul 2021 09:20:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6641F3886C65 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100409] C++ FE elides pure throwing call Date: Thu, 08 Jul 2021 09:20:38 +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: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2021 09:20:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100409 --- Comment #10 from Richard Biener --- (In reply to Richard Biener from comment #7) > Jason, any idea? diff --git a/gcc/cp/except.c b/gcc/cp/except.c index a8cea53cf91..cbc94dff790 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1050,7 +1050,7 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, = void * /*data*/) if (concept_check_p (fn)) return NULL_TREE; tree type =3D TREE_TYPE (fn); - gcc_assert (INDIRECT_TYPE_P (type)); + gcc_assert (INDIRECT_TYPE_P (type) || type =3D=3D unknown_type_node); type =3D TREE_TYPE (type); STRIP_NOPS (fn); @@ -1073,7 +1073,7 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, = void * /*data*/) to evaluate the noexcept-specifier's operand here, but that co= uld cause instantiations that would fail. */ } - if (!TYPE_NOTHROW_P (type)) + if (type =3D=3D unknown_type_node || !TYPE_NOTHROW_P (type)) return fn; } fixes all but the ICE for g++.dg/warn/noeffect4.C where we end up with an invalid CALL_EXPR: arg:0 readonly arg:0 side-effects tree_6 fn also notice how sizeof() doesn't have side-effects but the call has. I suppose that's somehow an "unevaluated" sizeof() expression we don't expect to hit expr_noexcept_p? OTOH noexcept(sizeof(foo())) might be "valid"? Changing the assert to if (INDIRECT_TYPE_P (type)) conditionalizing the use of 'type' beyond of course works. Aka diff --git a/gcc/cp/except.c b/gcc/cp/except.c index a8cea53cf91..623b83b8dc2 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1050,8 +1050,6 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, = void * /*data*/) if (concept_check_p (fn)) return NULL_TREE; tree type =3D TREE_TYPE (fn); - gcc_assert (INDIRECT_TYPE_P (type)); - type =3D TREE_TYPE (type); STRIP_NOPS (fn); if (TREE_CODE (fn) =3D=3D ADDR_EXPR) @@ -1073,7 +1071,8 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, = void * /*data*/) to evaluate the noexcept-specifier's operand here, but that co= uld cause instantiations that would fail. */ } - if (!TYPE_NOTHROW_P (type)) + if (!INDIRECT_TYPE_P (type) + || !TYPE_NOTHROW_P (TREE_TYPE (type))) return fn; } which leaves us with FAIL: g++.dg/warn/noeffect4.C -std=3Dgnu++98 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=3Dgnu++14 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=3Dgnu++17 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=3Dgnu++2a (test for warnings, line 84) not diagnosing sizeof (x++); // { dg-warning "no effect" } not sure what should happen to the x++ side-effect (throwing).=