Title
Unclear argument type for copy of exception object
Status
dr
Section
14.2 [except.throw]
Submitter
Jiang An

Created on 2023-05-31.00:00:00 last changed 3 weeks ago

Messages

Date: 2024-03-20.05:24:09

Proposed resolution (approved by CWG 2024-03-20):

  1. Change in 14.2 [except.throw] paragraph 5 as follows:

    When the thrown object is a class object, the constructor selected for the copy-initialization as well as the constructor selected for a copy-initialization considering the thrown object as an lvalue shall be non-deleted and accessible, even if the copy/move operation is elided (11.9.6 [class.copy.elision]). Let T denote the type of the exception object. Copy-initialization of an object of type T from an lvalue of type const T in a context unrelated to T shall be well-formed. If T is a class type, the selected constructor is odr-used (6.3 [basic.def.odr]) and The the destructor of T is potentially invoked (11.4.7 [class.dtor]).
Date: 2024-03-20.05:17:47

Proposed resolution (approved by CWG 2023-11-10) [SUPERSEDED]:

  1. Change in 6.3 [basic.def.odr] paragraph 9 as follows:

    An assignment operator function in a class is odr-used by an implicitly-defined copy assignment or move assignment function for another class as specified in 11.4.6 [class.copy.assign]. A constructor for a class is odr-used as specified in 9.4 [dcl.init] and when selected for the potential copy-initialization as specified in 14.2 [except.throw]. A destructor for a class is odr-used if it is potentially invoked (11.4.7 [class.dtor]).
  2. Change in 14.2 [except.throw] paragraph 5 as follows:

    When the thrown object is a class object, the constructor selected for the copy-initialization as well as the constructor selected for a copy-initialization considering the thrown object as an lvalue shall be non-deleted and accessible, even if the copy/move operation is elided (11.9.6 [class.copy.elision]). Let T denote the type of the exception object. Copy-initialization of an object of type T from an lvalue of type const T in a context unrelated to T shall be well-formed. If T is a class type, The the destructor of T is potentially invoked (11.4.7 [class.dtor]).
Date: 2023-11-10.17:41:13

CWG 2023-11-09

The drafting should also consider odr-use of the constructor potentially invoked for the copy-initialization.

Date: 2023-11-10.17:41:13

Proposed resolution (approved by CWG 2023-09-15) [SUPERSEDED]:

Change in 14.2 [except.throw] paragraph 5 as follows:

When the thrown object is a class object, the constructor selected for the copy-initialization as well as the constructor selected for a copy-initialization considering the thrown object as an lvalue shall be non-deleted and accessible, even if the copy/move operation is elided (11.9.6 [class.copy.elision]). Let T denote the type of the exception object. Copy-initialization of an object of type T from an lvalue of type const T in a context unrelated to any class shall be well-formed. If T is a class type, The the destructor of T is potentially invoked (11.4.7 [class.dtor]).
Date: 2024-03-15.00:00:00

[Accepted as a DR at the March, 2024 meeting.]

Subclause 14.2 [except.throw] paragraph 5 specifies:

When the thrown object is a class object, the constructor selected for the copy-initialization as well as the constructor selected for a copy-initialization considering the thrown object as an lvalue shall be non-deleted and accessible, even if the copy/move operation is elided (11.9.6 [class.copy.elision]). The destructor is potentially invoked (11.4.7 [class.dtor]).

This provision is for capturing a copy constructor for implementations not using reference-counted std::exception_ptrs, but that ought to be described separately from the "thrown object", which can be interpreted as the operand of the throw-expression.

History
Date User Action Args
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 05:20:48adminsetstatus: tentatively ready -> ready
2024-03-20 05:17:47adminsetmessages: + msg7646
2023-12-02 15:54:05adminsetstatus: review -> tentatively ready
2023-11-10 17:41:13adminsetmessages: + msg7514
2023-11-10 17:41:13adminsetmessages: + msg7513
2023-11-10 17:41:13adminsetstatus: drafting -> review
2023-11-10 14:27:11adminsetstatus: tentatively ready -> drafting
2023-09-15 21:51:11adminsetmessages: + msg7431
2023-09-15 21:51:11adminsetstatus: open -> tentatively ready
2023-05-31 00:00:00admincreate