On 6/11/20 3:50 PM, Iain Sandoe wrote:
Hi,

The reason that the code fails is that (by a somewhat complex
implied route), when a user adds a 'get-return-on-alloc-fail’
to their coroutine promise, this implies the use of some content
from <new>; we should not ICE because the user forgot that tho.

Jonathan and I were discussing whether there’s a better way than
including <new> in <coroutines> to make this less likely to happen.

The issue is that neither <coroutine> nor the user’s code overtly
use <new>; one has to know that the standard makes use of it
by implication… anyway that’s not the bug, but the background.

tested on Linux, and Darwin.
OK for master?
10.2?
thanks
Iain

ok, a couple of nits

========

The actual issue is that (in the testcase) std::nothrow is not
available.  So update the handling of the get-return-on-alloc-fail
to include the possibility that std::nothrow might not be
available.

gcc/cp/ChangeLog:

        * coroutines.cc (morph_fn_to_coro): Update handling of
        get-return-object-on-allocation-fail and diagnose missing
        std::nothrow.

gcc/testsuite/ChangeLog:

        * g++.dg/coroutines/pr95505.C: New test.
---
  gcc/cp/coroutines.cc                      | 43 +++++++++++------------
  gcc/testsuite/g++.dg/coroutines/pr95505.C | 26 ++++++++++++++
  2 files changed, 47 insertions(+), 22 deletions(-)
  create mode 100644 gcc/testsuite/g++.dg/coroutines/pr95505.C

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index f0b7e71633d..93f1e5ca30d 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3913,30 +3913,25 @@ morph_fn_to_coro (tree orig, tree *resumer, tree 
*destroyer)
    tree grooaf = NULL_TREE;
    tree dummy_promise = build_dummy_object (get_coroutine_promise_type (orig));
- /* We don't require this, so lookup_promise_method can return NULL... */
+  /* We don't require this, so lookup_promise_method can return NULL,
+     but, if the lookup succeeds, then the function must be usable.*/
 .<MISSING-SPACES>*/

-  if (fns && BASELINK_P (fns))
+  /* We don't require this, so lookup_promise_method can return NULL...  */
... to what?  Is this a repeat of the above rationale or something different?


nathan
--
Nathan Sidwell

Reply via email to