<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 8 February 2016 at 17:32, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@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">(sorry for the delay)<br><br>Here's some code that demonstrates the move problem:<br><br><div>TEST(ErrorOr, ImplicitConversionCausesMove) {</div><div> struct Source {</div><div> };</div><div> struct Destination {</div><div> Destination(const Source&){}</div><div> Destination(Source&&) = delete;</div><div> };</div><div> Source s;</div><div> ErrorOr<Destination> x = s;</div><div>}<br><br>with the 'std::move' the code calls the deleted ctor taking a Source&&, dropping the std::move gets it back on the right track.<br><br>Presumably we can remove the ErrorOr(T) ctor in favor of this more general perfectly forwarding one anyway, perhaps?</div></div></blockquote><div><br></div><div>That went well. Updated patch attached!</div><div><br></div><div>Nick</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 4, 2016 at 11:30 AM, Nick Lewycky <span dir="ltr"><<a href="mailto:nlewycky@google.com" target="_blank">nlewycky@google.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"><div class="gmail_extra"><div class="gmail_quote"><span>On 3 February 2016 at 21:41, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Drop the std::move (this would incorrectly move in this case, I think:<br><br>std::string s;<br>ErrorOr<std::string> g = s;<br><br>I think?</div></blockquote><div><br></div></span><div>I tried this case out, but it it matches "ErrorOr(T Val)" and doesn't call my new c'tor overload at all. Do you have a similar thing for me to try?</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"> Perhaps you could add a test case for a case like that to ensure the move does not occur (you'd need a type that recorded its move operations, etc)<br></div></blockquote><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Other than that, please commit</div></blockquote><div><br></div></span><div>I got feedback from Richard Smith off-list that I should also check for types that convert to std::error_code. I haven't been able to get that case to do anything wrong either.</div><div><br></div><div>More testcases added, but logic in ErrorOr not changed. Please review!</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><div><div>On Wed, Feb 3, 2016 at 6:58 PM, Nick Lewycky via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr">The attached patch changes ErrorOr to make this code:<div><br></div><div> ErrorOr<string> test() { return "literal"; }</div><div><br></div><div>work. Without this patch it fails because it would require two user-defined conversions in a row. Please review!</div><div><br></div><div>I'm not sure whether it's correct to describe this as "perfect forwarding"?<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div><br></div><div>Nick<br></div><div><br></div></font></span></div>
<br></div></div>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>