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

2022-09-25


1148. Copy elision and move construction of function parameters

Section: 11.9.6  [class.copy.elision]     Status: C++11     Submitter: DE     Date: 2010-08-03

[Voted into the WP at the November, 2010 meeting.]

N3092 comment DE 11

It is unclear whether copy elision is permitted when returning a parameter of class type. If not, it should still be possible to move, rather than copy, the return value.

Suggested resolution: Amend paragraph 34 to explicitly exclude function parameters from copy elision. Amend paragraph 35 to include function parameters as eligible for move-construction.

Proposed resolution (September, 2010):

  1. Change 11.4.5.3 [class.copy.ctor] paragraph 34 bullets 1 and 2 as follows:

  2. Change 11.4.5.3 [class.copy.ctor] paragraph 35 as follows:

    When the criteria for elision of a copy operation are met, or would be met save for the fact that the source object is a function parameter, and the object to be copied is designated by an lvalue, overload resolution...
[Drafting note: the change to paragraph 35 intentionally omits catch-clause parameters out of concern that a rethrow during the move would throw a stripped exception object. This should not be problematic in most cases, since exception objects are typically small.]