Title
When are parameter objects destroyed?
Status
cd4
Section
7.6.1.3 [expr.call]
Submitter
Hubert Tong

Created on 2014-02-25.00:00:00 last changed 45 months ago

Messages

Date: 2014-06-15.00:00:00

Notes from the June, 2014 meeting:

WG decided to make it unspecified whether parameter objects are destroyed immediately following the call or at the end of the full-expression to which the call belongs. This approach also resolves issue 1935.

Date: 2016-06-15.00:00:00

[Adopted at the June, 2016 meeting as part of paper P0135R1.]

According to 7.6.1.3 [expr.call] paragraph 4,

The lifetime of a parameter ends when the function in which it is defined returns. The initialization and destruction of each parameter occurs within the context of the calling function.

This presumably means that the destruction of the parameter object occurs before the end of the full-expression, unlike temporaries. This is not what current implementations do, however. It is not clear that a change to treat parameter objects like temporaries, to match existing practice, would be an improvement, however, as it would result in ABI breakage for implementations that destroy parameters in the called function.

See also issue 1935 for a related question regarding the handling of arguments to a placement allocation function and placement deallocation function.

History
Date User Action Args
2021-02-17 00:00:00adminsetstatus: drafting -> cd4
2014-07-07 00:00:00adminsetmessages: + msg5086
2014-07-07 00:00:00adminsetstatus: open -> drafting
2014-02-25 00:00:00admincreate