Skip to content

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

Open
@xmh0511

Description

@xmh0511

[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cwgIssue must be reviewed by CWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions