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 to select the constructor for the copy is first performed as if the object were designated by an rvalue. If overload resolution fails, or if the type of the first parameter of the selected constructor is not an rvalue reference to the object’s type (possibly cv-qualified), overload resolution is performed again, considering the object as an lvalue. —N3797, 12.8 [class.copy]/32
N4296 says the same thing, but much more verbosely: When the criteria for elision of a copy/move operation are met, but not for an exception-declaration, and the object to be copied is designated by an lvalue, or when the expression in a return statement is a (possibly parenthesized) id-expression that names an object with automatic storage duration declared in the body or parameter-declaration-clause of the innermost enclosing function or lambda-expression, overload resolution to select the constructor for the copy is first performed as if the object were designated by an rvalue. Looks to me as if GCC is correct and Clang is (/has always been) incorrect. –Arthur On Wed, Jul 29, 2015 at 2:57 AM, Sebastian Redl < sebastian.r...@getdesigned.at> wrote: > > > On 28.07.2015 21:06, Richard Trieu wrote: > >> Author: rtrieu >> Date: Tue Jul 28 14:06:16 2015 >> New Revision: 243463 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=243463&view=rev >> Log: >> Do not give a -Wredundant-move warning when removing the move will result >> in an >> error. >> >> If the object being moved has a move constructor and a deleted copy >> constructor, >> std::move is required, otherwise Clang will give a deleted constructor >> error. >> >> Is that actually correct behavior by Clang? GCC 5.2 compiles the > following without problems: > > struct A { > A() {} > A(A&&) {} > }; > > struct B { > B(A) {} > }; > > B fn(A a) { > return a; > } > > int main() { > fn(A()); > } > > Sebastian > _______________________________________________ > cfe-commits mailing list > cfe-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits