cplusplus / cplusplus/draft

[expr.await] The lifetime of parameters and variables that are defined in a coroutine

Open
#4,867 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

[expr.await] p5

Otherwise, control flow returns to the current coroutine caller or resumer ([dcl.fct.def.coroutine]) without exiting any scopes ([stmt.jump]).

However, whether a variable with automatic storage duration is active or not is totally defined in [stmt.dcl] p3, which means "without exiting any scopes" seems to expound nothing. According to [basic.stc.auto] p1, the storage duration of the parameters and variables defined in a coroutine all have automatic storage duration, hence, their lifetimes are governed by [stmt.dcl] p3. Since what [expr.await] p5 says and [stmt.dcl] p3 says that

when a function returns, Q is after its body.

the lifetime of the parameters of a coroutine has ended when the first suspension occurs (which returns to the caller or resume, that is, Q is after its body). However, it cannot interpret the lifetimes of these variables defined in the body, that is, a suspension may not end their lifetimes.

If we admit the effect of "without exiting any scopes", which in turn, cannot interpret the lifetimes of the parameters of a coroutine, since the parameter scope does not exit out. In conclusion, regardless of [stmt.dcl] p3 or "without exiting any scopes", neither of them can interpret both the lifetime of parameters of the coroutine and the variables in that coroutine.

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

Read [expr.await] p5 alongside [stmt.dcl] p3, [basic.stc.auto] p1, and [dcl.fct.def.coroutine]. Determine how suspension affects the lifetimes of coroutine parameters and body variables, then clarify the standard wording so both cases are specified consistently.

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.