Skip to content

[stmt.jump]/2 Wording does not apply to objects whose lifetime has ended #2871

Closed
@sdkrystian

Description

@sdkrystian

Issue

http://eel.is/c++draft/stmt.jump#2 says that objects with automatic storage duration are destroyed when leaving scope, however, if you end the lifetime of an object prematurely, it no longer exists, and since the wording in the standard only applies to objects during their lfetime, there would be no object to destroy, as the wording wouldn't apply an object who's lifetime is over.

Proposed Wording to fix:

[stmt.jump]/2
On exit from a scope (however accomplished), variables that refer to objects with automatic storage duration declared in that scope will be destroyed in the reverse order of their declaration. If a variable does not refer to an object and the type of the variable has a non-trivial destructor, the behavior is undefined.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions