This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1935. Reuse of placement arguments in deallocation

Section: 7.6.2.8  [expr.new]     Status: CD5     Submitter: Hubert Tong     Date: 2014-06-04

[Resolved by CWG1880 (November, 2014) and CWG2177 (November, 2017).]

The description in 7.6.2.8 [expr.new] paragraph 23 regarding calling a deallocation function following an exception during the initialization of an object resulting from a placement new-expression says,

If a placement deallocation function is called, it is passed the same additional arguments as were passed to the placement allocation function, that is, the same arguments as those specified with the new-placement syntax. If the implementation is allowed to make a copy of any argument as part of the call to the allocation function, it is allowed to make a copy (of the same original value) as part of the call to the deallocation function or to reuse the copy made as part of the call to the allocation function. If the copy is elided in one place, it need not be elided in the other.

This seems curious, as it allows reuse of a parameter object that presumably is destroyed immediately upon the return of the allocation function (but see issue 1880 for a question about the timing of such destructions).

Notes from the November, 2014 meeting:

The resolution for issue 1880 should mostly resolve this issue. The resolution should handle the case in which an object can only be constructed into the parameter object and neither copied nor moved.

Additional notes (July, 2022):

Issue 1880 permitted the destruction of parameter objects at the end of the full-expression enclosing the function call. Issue 2177 clarified the exceptions to the parameter object reuse.

Additional notes (CWG teleconference 2022-08-12):

This issue is resolved by issues 1880 and 2177. Reusing the parameter objects of the placement-new call for the placement-delete invocation is intentional.