Skip to content

CWG2944 [expr.throw] Throw expressions should be indivisible #626

Description

@eisenwave

Reference (section label): [expr.throw]

Issue description

It is unclear what happens when two throw-expressions are unsequenced, such as in:

(throw /* ... */, 0) + (throw /* ... */, 0);

As per [except.throw] paragraph 1, this results in two unsequenced transfers of control to the caller, contrary to co_await expressions, which are indivisible and non-interleavable following CWG2466 ([intro.execution] paragraph 11).

Suggested resolution

Update [intro.execution] paragraph 11 as follows:

For each function invocation, evaluation of a throw-expression, or evaluation of an await-expression F, each evaluation that does not occur within F but is evaluated on the same thread and as part of the same signal handler (if any) is either sequenced before all evaluations that occur within F or sequenced after all evaluations that occur within F;

Analogous to [expr.await] Note 2, append a note to [expr.throw] paragraph 2 as follows:

[...] from the (possibly converted) operand.

[Note: With respect to sequencing, a throw-expression is indivisible ([intro.execution]). — end note]

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