Title
Bypassing non-copy/move constructor copying
Status
cd4
Section
11.4.5.3 [class.copy.ctor]
Submitter
Richard Smith

Created on 2012-11-26.00:00:00 last changed 40 months ago

Messages

Date: 2014-06-15.00:00:00

Notes from the June, 2014 meeting:

CWG felt that the requirements for accessibility should be removed, in line with the idea making all access public in a program should not change its semantics. Similarly, the prohibition of non-trivial functions was not desirable. The approach should be to recognize the extra copy as a temporary object and deal explicitly with its lifetime.

Date: 2014-07-07.00:00:00

Additional note, May, 2014:

Questions have been raised regarding this resolution. In particular, the interaction of the “extra copy” with copy elision, lifetime, and access checking context are not specified. In addition, some concern has also been expressed regarding the requirement that the trivial copy/move constructor be accessible. The issue is being returned to "review" status for discussion of these points.

Date: 2013-04-15.00:00:00

Proposed resolution (April, 2013):

Add the following as a new paragraph following 11.4.5.3 [class.copy.ctor] paragraph 1:

When an object of class type X is passed to or returned from a function, if X has a trivial, accessible copy or move constructor that is not deleted, and X has no non-trivial copy constructors, move constructors, or destructors, implementations are permitted to perform an additional copy or move of the object using the trivial constructor (even if it would not be selected by overload resolution to perform a copy or move of the object). [Note: This latitude is granted to allow objects of class type to be passed to or returned from functions in registers. —end note]

See also issue 1928.

Date: 2016-06-15.00:00:00

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

Copy initialization in some cases uses constructors that are not copy/move constructors (e.g., a specialization of a constructor template might be selected by overload resolution, or in copy-list-initialization, any constructor could be selected). Some ABIs require that an object of certain class types be passed in a register (effectively using the trivial copy/move constructor), even if the class has a non-trivial constructor that would be selected to do the copy. The Standard should be changed to permit this usage.

History
Date User Action Args
2020-12-15 00:00:00adminsetstatus: drafting -> cd4
2014-07-07 00:00:00adminsetmessages: + msg5093
2014-07-07 00:00:00adminsetstatus: review -> drafting
2014-05-27 00:00:00adminsetmessages: + msg4993
2014-05-27 00:00:00adminsetstatus: ready -> review
2014-03-03 00:00:00adminsetstatus: review -> ready
2013-05-03 00:00:00adminsetmessages: + msg4321
2013-05-03 00:00:00adminsetstatus: open -> review
2012-11-26 00:00:00admincreate