Skip to content

[except.ctor] Return object destruction from throwing postcondition evaluation #988

Description

@notadragon

Full name of submitter (unless configured in github; will be published with the issue): Joshua Berne

Reference (section label): [except.ctor] p2

Link to reflector thread (if any):

Issue description: There is special dispensation in this paragraph to destroy the return object that was created already when an exception escapes the destruction of temporaries or local variables after the return statement has been evaluated. We need the same dispensation for an exception escaping the evaluation of postconditions (because the return object doesn't fall under the general rules for automatic variables because it's not automatic.

The existing paragraph also doesn't seem like it should be about "an exception thrown during the destruction..." but rather an exception escaping that destruction. (An exception thrown and then caught during that destruction should not result in destroying the return object, because that would be insane).

Suggested resolution:

Each object with automatic storage duration is destroyed if it has been constructed, but not yet destroyed,
since the try block was entered. If an exception is thrown during from the destruction of temporaries or local
variables for a return statement (8.8.4), or from the evaluation of postcondition assertions of the enclosing function ([expr.call]), the destructor for the returned object (if any) is also invoked. The
objects are destroyed in the reverse order of the completion of their construction.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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