<div dir="ltr"><span id="docs-internal-guid-d01b9d6b-db22-3da4-4e18-8d2e82502e44"><p dir="ltr" style="margin-top:6pt;margin-bottom:0pt">When the criteria for elision of a copy operation are met[,] <b>or would be met save for the fact that the source object is a function parameter,</b> 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<br></p><p dir="ltr" style="margin-top:6pt;margin-bottom:0pt"><br>
                
        
        
                </p><p style="margin-top:6pt;margin-bottom:0pt">N4296 says the same thing, but much more verbosely:</p><div class="page" title="Page 309">
                        <div class="layoutArea">
                                <div class="column">
                                        <p><span style="font-size:10.000000pt;font-family:'LMRoman10'">When the criteria for elision of a copy/move operation are met, but not for an </span><span style="font-size:9.000000pt;font-family:'LMRoman9';font-style:italic">exception-declaration</span><span style="font-size:10.000000pt;font-family:'LMRoman10'">, and the
object to be copied is designated by an lvalue, or when the </span><span style="font-size:10.000000pt;font-family:'LMRoman10';font-style:italic">expression </span><span style="font-size:10.000000pt;font-family:'LMRoman10'">in a </span><span style="font-size:10.000000pt;font-family:'LMMono10'">return </span><span style="font-size:10.000000pt;font-family:'LMRoman10'">statement is a (possibly
parenthesized) </span><span style="font-size:10.000000pt;font-family:'LMRoman10';font-style:italic">id-expression </span><span style="font-size:10.000000pt;font-family:'LMRoman10'">that names an object with automatic storage duration declared in the body or
</span><span style="font-size:10.000000pt;font-family:'LMRoman10';font-style:italic">parameter-declaration-clause </span><span style="font-size:10.000000pt;font-family:'LMRoman10'">of the innermost enclosing function or </span><span style="font-size:10.000000pt;font-family:'LMRoman10';font-style:italic">lambda-expression</span><span style="font-size:10.000000pt;font-family:'LMRoman10'">, overload resolution
to select the constructor for the copy is first performed as if the object were designated by an rvalue. </span></p>
                                </div>
                        </div>
                </div>Looks to me as if GCC is correct and Clang is (/has always been) incorrect.<br><br>–Arthur</span><div><span><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 29, 2015 at 2:57 AM, Sebastian Redl <span dir="ltr"><<a href="mailto:sebastian.redl@getdesigned.at" target="_blank">sebastian.redl@getdesigned.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 28.07.2015 21:06, Richard Trieu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: rtrieu<br>
Date: Tue Jul 28 14:06:16 2015<br>
New Revision: 243463<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243463-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=_L10PmZrnBYWPkOd1zjulZ_AU7nSHXR5hcD-EeR36K0&s=7I1ON7EyKTaZa2RuYMve8B75NKVHPYcIDAGzSs_Qlik&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=243463&view=rev</a><br>
Log:<br>
Do not give a -Wredundant-move warning when removing the move will result in an<br>
error.<br>
<br>
If the object being moved has a move constructor and a deleted copy constructor,<br>
std::move is required, otherwise Clang will give a deleted constructor error.<br>
<br>
</blockquote>
Is that actually correct behavior by Clang? GCC 5.2 compiles the following without problems:<br>
<br>
struct A {<br>
    A() {}<br>
    A(A&&) {}<br>
};<br>
<br>
struct B {<br>
  B(A) {}<br>
};<br>
<br>
B fn(A a) {<br>
    return a;<br>
}<br>
<br>
int main() {<br>
    fn(A());<br>
}<br>
<br>
Sebastian<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>