<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 29, 2015 at 11:51 AM, Arthur O'Dwyer <span dir="ltr"><<a href="mailto:arthur.j.odwyer@gmail.com" target="_blank">arthur.j.odwyer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><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 title="Page 309">
                        <div>
                                <div>
                                        <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></span></div></blockquote><div><br></div><div>No, the conditions for copy elision include that the source and destination type are the same (up to cv qualification), so the old and new rules are quite different. This is <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.open-2Dstd.org_jtc1_sc22_wg21_docs_cwg-5Fdefects.html-231579&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=sVLMToItVRA4Pidbl1l3ywgXx48tADunIdcYUAK9SI4&s=oyGgcBobZUwTup34qziUfGj1-Y18pVq5gEqh7Byodfo&e=">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579</a>, which Clang does not yet implement.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span>–Arthur</span><div><span><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">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></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
On 28.07.2015 21:06, Richard Trieu wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Author: rtrieu<br>
Date: Tue Jul 28 14:06:16 2015<br>
New Revision: 243463<br>
<br></span>
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><span class=""><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>
</span></blockquote><span class="">
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>
</span></blockquote></div><br></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">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>
<br></blockquote></div><br></div></div>