Title
Mishandling of lambda coroutines
Status
open
Section
9.6.4 [dcl.fct.def.coroutine]
Submitter
Jiang An

Created on 2025-07-03.00:00:00 last changed 1 month ago

Messages

Date: 2025-07-03.00:00:00

(From submission #721.)

Subclause 9.6.4 [dcl.fct.def.coroutine] paragraph 3 and paragraph 4 do not properly handle function call operators of lambdas that are coroutines. In particular, *this does not denote the lambda's closure object and a captureless lambda should be treated like a static member function, because the result of a captureless lambda's conversion function does not take a pointer to the closure object.

Possible resolution:

  1. Change in 9.6.4 [dcl.fct.def.coroutine] paragraph 3 as follows:

    The promise type of a coroutine is std::coroutine_traits<R, P1 , . . . , Pn >::promise_type, where R is the return type of the function, and P1 . . . Pn is the sequence of types of the non-object function parameters, preceded by the type of the object parameter (9.3.4.6 [dcl.fct]) if the coroutine is a non-static member function that is not a member of the closure type for a lambda-expression with no lambda-capture and no explicit object parameter (7.5.6.2 [expr.prim.lambda.closure]). The promise type shall be a class type.
  2. Change in 9.6.4 [dcl.fct.def.coroutine] paragraph 4 as follows:

    A this-eligible function is an implicit object member function that is not a member of the closure type for a lambda-expression with no lambda-capture. In the following, pi is an lvalue of type Pi , where p1 denotes the object parameter and pi+1 denotes the ith non-object function parameter for an implicit object member this-eligible function, and pi denotes the ith function parameter otherwise. For an implicit object member this-eligible function, q1 is an lvalue that denotes *this or, if the function is a member of a closure type, the closure object; any other qi is an lvalue that denotes the parameter copy corresponding to pi , as described below.
History
Date User Action Args
2025-07-03 00:00:00admincreate