Skip to content

CWG2711 [except.throw] It is not specified what the exception object is copy-initialized from #280

Closed
cplusplus/draft
#6328

Description

@t3nsor

Full name of submitter: Brian Bi

Reference (section label): [except.throw]

Issue description: As pointed out by user 0x5f3759df on Stack Overflow, the normative wording in [expr.throw] and [except.throw] respectively specify the type of the exception object and the fact that the exception object is copy-initialized, but do not appear to specify that the exception object is copy-initialized from the assignment-expression operand.

Suggested resolution: Edit [except.throw]/3:

Throwing an exceptionA throw-expression ([expr.throw]) with an operand copy-initializes (9.4, 11.4.5.3) a temporary object, called the exception object, from its operand. If the type of the exception object would be an incomplete type, an abstract class type (11.7.4), or a pointer to an incomplete type other than cv void the program is ill-formed.

Activity

  1. jensmaurer commented on Mar 30, 2023

    @jensmaurer
    Member

    This isn't good; there are situations in the language where we throw exceptions without a throw-expression (for example, a failed dynamic cast or a failed typeid).

    We still want to initialize an exception object in these cases.

  2. jensmaurer commented on Mar 30, 2023

    @jensmaurer
    Member
  3. changed the title [-][except.throw] It is not specified what the exception object is copy-initialized from[/-] [+]CWG2711 [except.throw] It is not specified what the exception object is copy-initialized from[/+] on Mar 30, 2023
  4. t3nsor commented on Mar 30, 2023

    @t3nsor
    Author

    Good catch. Thanks for fixing the wording.

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