cplusplus / cplusplus/draft

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

Open
#5,295 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cwg not-editorial
Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the wording cited from [dcl.fct.def.coroutine] and [coroutine.handle.resumption], then inspect the linked Compiler Explorer example to understand the resumer behavior at #1. Determine whether the standard text needs clarification about a resumer that is not a function; done requires an agreed wording resolution for the coroutine rules.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.