On 2/7/20 1:06 PM, Iain Sandoe wrote:
Hi,

This is the first of the (small number of) anticipated changes to bring
the implementation into line with the latest published C++20 draft (this
is now expected to be very close to the final, although some wording
might still be adjusted).

The allocation for the coroutine state frame is quite flexible - which means
in reality a number of permutations to cater for and to test for.

Partial or complete adoption of p2014r0 would be additive to this, but it
seems better to me to separate changes for that to a future patch.

Because of the number of permutations, the error messages are somewhat
long-winded in an effort to point the user to the specific problem.

OK for trunk?
thanks
Iain

========

This updates the coroutine frame allocation and deallocation usage to
match n4849.

[dcl.fct.def.coroutine] /9, /10, /12.

9 An implementation may need to allocate additional storage for a coroutine.
   This storage is known as the coroutine state and is obtained by calling a
   non-array allocation function.  The allocation function’s name is looked up
   in the scope of the promise type.  If this lookup fails, the allocation
   function’s name is looked up in the global scope.  If the lookup finds an
   allocation function in the scope of the promise type, overload resolution
   is performed on a function call created by assembling an argument list.
   The first argument is the amount of space requested, and has type
   std::size_t.  The lvalues p1 . . . pn are the succeeding [user's function]
   arguments. If no viable function is found, overload resolution is performed
   again on a function call created by passing just the amount of space required
   as an argument of type std::size_t.

10 The unqualified-id get_return_object_on_allocation_failure is looked up in
   the scope of the promise type by class member access lookup. If any
   declarations are found, then the result of a call to an allocation function
   used to obtain storage for the coroutine state is assumed to return nullptr
   if it fails to obtain storage, and if a global allocation function is
   selected, the ::operator new(size_t, nothrow_t) form is used. The allocation
   function used in this case shall have a non-throwing noexcept-specification.
   If the allocation function returns nullptr, the coroutine returns control to
   the caller of the coroutine and the return value is obtained by a call to
   T::get_return_object_on_allocation_failure(), where T is the promise type.

12 The deallocation function’s name is looked up in the scope of the promise
   type. If this lookup fails, the deallocation function’s name is looked up in
   the global scope.  If deallocation function lookup finds both a usual
   deallocation function with only a pointer parameter and a usual deallocation
   function with both a pointer parameter and a size parameter, then the
   selected deallocation function shall be the one with two parameters.
   Otherwise, the selected deallocation function shall be the function with one
   parameter. If no usual deallocation function is found, the program is ill-
   formed.  The selected deallocation function shall be called with the address
   of the block of storage to be reclaimed as its first argument.  If a
   deallocation function with a parameter of type std::size_t is used, the size
   of the block is passed as the corresponding argument.

gcc/cp/ChangeLog:

2020-02-07  Iain Sandoe  <i...@sandoe.co.uk>

        * coroutines.cc (build_actor_fn): Implement deallocation function
        selection per n4849, dcl.fct.def.coroutine bullet 12.
        (morph_fn_to_coro): Implement allocation function selection per
        n4849, dcl.fct.def.coroutine bullets 9 and 10.

gcc/testsuite/ChangeLog:


This is ok.  I was having a dumb wrt to the type_size thing we talked about.


nathan


--
Nathan Sidwell

Reply via email to