https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115731

Arsen Arsenović <arsen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arsen at gcc dot gnu.org

--- Comment #2 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
I think MSVC also is not passing the lambda to the promise type.  Removing the
default constructor from your attachment (as well as the member example in
main) leads to:

  <source>(33): error C2512: 'coro::promise_type::promise_type': no appropriate
default constructor available
  <source>(18): note: could be 'coro::promise_type::promise_type(T &&)'
  <source>(33): note: 'coro::promise_type::promise_type(T &&)': expects 1
arguments - 0 provided
  <source>(33): note: while trying to match the argument list '()'

I think this is correct, per [dcl.fct.def.coroutine]#5.7:

  promise-constructor-arguments is determined as follows: overload resolution
is performed on a promise constructor call created by assembling an argument
list q_1...q_n.
  If a viable constructor is found ([over.match.viable]), then
promise-constructor-arguments is (q_1, ..., q_n), otherwise
promise-constructor-arguments is empty, ...

... where ([dcl.fct.def.coroutine]#4):

  In the following, p_i is an lvalue of type P_i, where p_1 denotes the object
parameter and pi+1 denotes the ith non-object function parameter for an
implicit object member function, and p_i denotes the i_th function parameter
otherwise.
  For an implicit object member function, q_1 is an lvalue that denotes *this;
any other q_i is an lvalue that denotes the parameter copy corresponding to
p_i, as described below.

... but I don't think a lambda is an implicit object member function
([dcl.fct]#6) because:

  An implicit object member function is a non-static member function without an
explicit object parameter.

... so, I think the fix is to not pass that argument.

Reply via email to