Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dcl.fct.def.coroutine] The resumer of a coroutine may not be a function CWG2613 #5295

Open
xmh0511 opened this issue Feb 15, 2022 · 2 comments
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Feb 15, 2022

Task task(){
   std::cout<<"in task\n";
   int r = co_await Line();
   std::cout<<"resumed\n";
   co_return r;
}
auto r = task();
auto c = (r.coro_.resume(),0);  // #1
auto f = [](){
    std::cout<<"invoked\n";
    return 0;
}();
int main(){}

#1 is a declaration where its initializer expression will invoke the resumption member function of the coroutine. We just state that:

A suspended coroutine can be resumed to continue execution by invoking a resumption member function ([coroutine.handle.resumption]) of a coroutine handle ([coroutine.handle]) that refers to the coroutine. The function that invoked a resumption member function is called the resumer.

and we have specified that

A coroutine returns to its caller or resumer ([dcl.fct.def.coroutine]) by the co_­return statement or when suspended ([expr.await]).

Obviously, in this case, the call of the resumption member function at #1 causes the coroutine to be resumed, and the co_return statement can cause the coroutine to return to its resumer, which means the lambda will be subsequently invoked. The complete example is here. The implementation admits that the context at #1 is also a so-called resumer.

@jensmaurer jensmaurer added cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. labels Aug 24, 2022
@jensmaurer jensmaurer changed the title The resumer of a coroutine may not be a function [dcl.fct.def.coroutine] The resumer of a coroutine may not be a function Aug 24, 2022
@jensmaurer jensmaurer changed the title [dcl.fct.def.coroutine] The resumer of a coroutine may not be a function [dcl.fct.def.coroutine] The resumer of a coroutine may not be a function CWG2613 Aug 24, 2022
@jensmaurer
Copy link
Member

CWG2613

@frederick-vs-ja
Copy link
Contributor

Should have been fixed by #5984 (d9dc415).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
3 participants