public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-100409-4-VSysza8r5i@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-100409-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100409 --- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> --- (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 = TREE_TYPE (fn); - gcc_assert (INDIRECT_TYPE_P (type)); + gcc_assert (INDIRECT_TYPE_P (type) || type == unknown_type_node); type = 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 could cause instantiations that would fail. */ } - if (!TYPE_NOTHROW_P (type)) + if (type == 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 <sizeof_expr 0x7ffff66ce940 type <integer_type 0x7ffff65617e0 long unsigned int> readonly arg:0 <call_expr 0x7ffff6550738 type <integer_type 0x7ffff65615e8 int> side-effects tree_6 fn <component_ref 0x7ffff66cf300 type <method_type 0x7ffff66a5f18> 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 = TREE_TYPE (fn); - gcc_assert (INDIRECT_TYPE_P (type)); - type = TREE_TYPE (type); STRIP_NOPS (fn); if (TREE_CODE (fn) == 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 could 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=gnu++98 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=gnu++14 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=gnu++17 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=gnu++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).
next prev parent reply other threads:[~2021-07-08 9:20 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-04 6:45 [Bug c++/100409] New: " rguenth at gcc dot gnu.org 2021-05-04 6:46 ` [Bug c++/100409] " rguenth at gcc dot gnu.org 2021-05-05 8:02 ` rguenth at gcc dot gnu.org 2021-07-08 7:25 ` rguenth at gcc dot gnu.org 2021-07-08 8:19 ` harald at gigawatt dot nl 2021-07-08 8:38 ` rguenth at gcc dot gnu.org 2021-07-08 8:38 ` rguenth at gcc dot gnu.org 2021-07-08 8:39 ` rguenth at gcc dot gnu.org 2021-07-08 8:44 ` rguenth at gcc dot gnu.org 2021-07-08 9:17 ` harald at gigawatt dot nl 2021-07-08 9:20 ` rguenth at gcc dot gnu.org [this message] 2021-07-08 9:41 ` rguenth at gcc dot gnu.org 2021-07-08 13:15 ` mpolacek at gcc dot gnu.org 2021-07-08 13:53 ` jason at gcc dot gnu.org 2021-07-08 14:09 ` rguenth at gcc dot gnu.org 2021-07-08 15:13 ` jason at gcc dot gnu.org 2021-07-08 22:06 ` mpolacek at gcc dot gnu.org 2022-01-05 14:41 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-100409-4-VSysza8r5i@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).