Skip to content

CWG2976 [stmt.dcl] p2 Destruction of variables with automatic storage duration on coroutine exit #656

Description

@dedlocc

Full name of submitter: Artem Koton

Reference (section label): [stmt.dcl] p2

Issue description:

P1787 changed the wording of [dcl.fct.def.coroutine/11] regarding the destruction of variables with automatic storage duration from:

In the latter case objects with automatic storage duration that are in scope at the suspend point are destroyed in the reverse order of the construction.

to:

In the latter case, control in the coroutine is considered to be transferred out of the function ([stmt.dcl/2]).

According to [stmt.dcl/2]:

Upon each transfer of control (including sequential execution of statements) within a function from point P to point Q, all block variables with automatic storage duration that are active at P and not at Q are destroyed in the reverse order of their construction.

This only applies to transferring control "within a function", which does not seem to cover the case for coroutines. If so, there currently appears to be no wording specifying how local variables are destroyed when a coroutine is exited.

Suggested resolution:

Clarify the wording of [stmt.dcl/2] to cover transfers of control out of a function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions