<div class="gmail_quote">On Fri, Apr 20, 2012 at 2:35 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com">eli.friedman@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 class="im">On Fri, Apr 20, 2012 at 11:46 AM, Richard Smith<br>
<<a href="mailto:richard-llvm@metafoo.co.uk">richard-llvm@metafoo.co.uk</a>> wrote:<br>
</div><div class="im">> Author: rsmith<br>
> Date: Fri Apr 20 13:46:14 2012<br>
> New Revision: 155218<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=155218&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=155218&view=rev</a><br>
> Log:<br>
> Fix bug where a class's (deleted) copy constructor would be implicitly given a<br>
> non-const reference parameter type if the class had any subobjects with deleted<br>
> copy constructors. This causes a rejects-valid if the class's copy constructor<br>
> is explicitly defaulted (as happens for some implementations of std::pair etc).<br>
<br>
</div>Is this the same issue as <a href="http://llvm.org/bugs/show_bug.cgi?id=12575" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=12575</a> ?</blockquote><div><br></div><div>Yes, thanks.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">> +struct DeletedNonConstCopy {<br>
> +  DeletedNonConstCopy(DeletedNonConstCopy &) = delete;<br>
> +};</div></div></blockquote><div>[...] </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">> +struct E : DeletedNonConstCopy {};<br></div>
</div></blockquote><div>[...] </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">> +  friend E::E(E &);<br>
<br>
</div></div>I'm not sure I understand the reasoning for E; why shouldn't it be<br>
E::E(const E&)?  DeletedConstCopy and DeletedNonConstCopy are the same<br>
in the sense that neither can be copy-constructed from a const object.</blockquote><div><br></div><div>Quoth the standard ([class.copy] p8):</div><div><br></div><div>"The implicitly-declared copy constructor for a class X will have the form</div>
<div>X::X(const X&)</div><div>if</div><div>— each direct or virtual base class B of X has a copy constructor whose first parameter is of type const</div><div>B& or const volatile B&, and</div><div>— for all the non-static data members of X that are of a class type M (or array thereof), each such class</div>
<div>type has a copy constructor whose first parameter is of type const M& or const volatile M&.119</div><div>Otherwise, the implicitly-declared copy constructor will have the form</div><div>X::X(X&)"</div>
<div><br></div><div>DeletedNonConstCopy does not have a copy constructor whose first parameter is of type 'const DeletedNonConstCopy&'.</div><div><br></div><div>FWIW, I find it very strange that we are required to issue a diagnostic if a defaulted constructor has the wrong argument type, even if it would have been defined as deleted anyway.</div>
</div>