<div dir="ltr">Yeah, not sure either.<br><br>The discussion about minimum compatibility usually comes down to what version is available on long-term OS releases.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 2, 2020 at 12:38 PM George Rimar <<a href="mailto:grimar@accesssoftek.com">grimar@accesssoftek.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<p>> <span style="color:rgb(33,33,33);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)">Is the code currently broken?</span><br>
</p>
<p><br>
</p>
<p>I don't know. <span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)">
Perhaps the code is fine, </span>I did not try to compile LLVM with all that compilers</p>
<p>that we claim as supported though. <span style="font-size:12pt">I</span><span style="font-size:12pt"> just *guess* that we don't have a bot
</span><span style="font-size:12pt">t</span><span style="font-size:12pt">hat builds LLVM with </span><span style="font-size:12pt">Clang 3.5,</span></p>
<p><span style="font-size:12pt">for example. It sounds like a bit too old </span>
<span style="font-size:12pt">version to me to use (released in the middle of <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">2014, AFAIK</span>).</span></p>
<p><br>
</p>
<div id="gmail-m_-7322763380935641288Signature">
<div name="divtagdefaultwrapper">
<div><font size="2">
<div>Best regards,<br>
George | Developer | <span style="background-color:rgb(255,255,255);color:rgb(33,33,33);font-family:Calibri,sans-serif;font-size:13.3333px">Access Softek, Inc</span></div>
</font></div>
</div>
</div>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7322763380935641288divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>><br>
<b>Отправлено:</b> 2 октября 2020 г. 22:04<br>
<b>Кому:</b> George Rimar<br>
<b>Копия:</b> Alexander Shaposhnikov; Richard Smith; llvm-dev; Lang Hames; James Henderson; <a href="mailto:avl.lapshin@gmail.com" target="_blank">avl.lapshin@gmail.com</a><br>
<b>Тема:</b> Re: [EXTERNAL] Re: [llvm-dev] preferred way to return expected values</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Fri, Oct 2, 2020 at 1:48 AM George Rimar <<a href="mailto:grimar@accesssoftek.com" target="_blank">grimar@accesssoftek.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Thanks, David!<br>
</p>
<p><br>
</p>
<p>Few minor additions to the topic:<br>
</p>
<p><br>
</p>
<p>> <span style="color:rgb(33,33,33);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)">I'm not sure which MSVC version on godbolt would be "MSVC 2017" that the LLVM docs refer to</span></p>
<p><br>
</p>
<p>I've found that the minimal available version of MSVC on godbolt is "WINE MSVC 2015: x64 msvc v19.0 (WINE)".<br>
</p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)">Your sample compiles fine with it: </span><a href="https://godbolt.org/z/hsPneK" style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)" target="_blank">https://godbolt.org/z/hsPneK</a><br>
</p>
<p><br>
</p>
<p>Also, I've tried with "<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)">x64 msvc v19.</span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)">10
(WINE)</span>" (<a href="https://godbolt.org/z/vaqsPY" target="_blank">https://godbolt.org/z/vaqsPY</a>)<br>
</p>
<p>wiki says that v19.10 corresponds to <span style="font-size:12pt">Visual Studio 2017 version 15.0 </span><span style="font-size:12pt">(<a href="https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B" target="_blank">https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B</a>),</span></p>
<p><span style="font-size:12pt">i.e.</span><span style="font-size:12pt"> it is </span><span style="font-size:12pt">MSVS 2017 without updates. The sample also feels fine.</span></p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="color:rgb(33,33,33);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)">> Looks like we would need to bump the minimum Clang up from 3.5 to at least 3.9 to allow returns with implicit moves that
include conversions.</span><br>
</p>
<p><br>
</p>
<p><span style="font-size:12pt">Perhaps, we could have a bot to check that LLVMs </span>
<span style="font-size:12pt">codebase is </span><span style="font-size:12pt">compilable</span><span style="font-size:12pt"> with compilers we claim to support.</span></p>
</div>
</blockquote>
<div>Generally good to do, yes, but someone's got to pay for/setup the resources, etc. <br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<p><span style="font-size:12pt">I am not sure it is not a overkill though, but could help either to keep the documentation up to date or fix the code to match it.</span></p>
</div>
</blockquote>
<div>Is the code currently broken?<br>
<br>
- Dave<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<p><br>
</p>
<div id="gmail-m_-7322763380935641288gmail-m_2002668242944554553Signature">
<div name="divtagdefaultwrapper">
<div><font size="2">
<div>Best regards,<br>
George | Developer | <span style="background-color:rgb(255,255,255);color:rgb(33,33,33);font-family:Calibri,sans-serif;font-size:13.3333px">Access Softek, Inc</span></div>
</font></div>
</div>
</div>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7322763380935641288gmail-m_2002668242944554553divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>><br>
<b>Отправлено:</b> 1 октября 2020 г. 22:00<br>
<b>Кому:</b> George Rimar<br>
<b>Копия:</b> Alexander Shaposhnikov; Richard Smith; llvm-dev; Lang Hames; James Henderson;
<a href="mailto:avl.lapshin@gmail.com" target="_blank">avl.lapshin@gmail.com</a><br>
<b>Тема:</b> Re: [EXTERNAL] Re: [llvm-dev] preferred way to return expected values</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Oct 1, 2020 at 2:08 AM George Rimar <<a href="mailto:grimar@accesssoftek.com" target="_blank">grimar@accesssoftek.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<p>FWIW, <span style="font-size:12pt">I've performed an experiment with the code below at godbolt.</span></p>
<div>(used -O2, <a href="https://godbolt.org/z/nY95nh" target="_blank">https://godbolt.org/z/nY95nh</a>)<br>
</div>
<div><br>
</div>
<div>```</div>
<div>#include <vector></div>
<div>#include "llvm/Support/Error.h"</div>
<div><br>
</div>
<div>llvm::Expected<std::vector<int>> foo() {</div>
<div> std::vector<int> V;</div>
<div> V.push_back(0);</div>
<div> return V;</div>
<div>}</div>
<div>```<br>
</div>
</div>
</blockquote>
<div><br>
I think the easiest and portable way to test this functionality would be more like:<br>
<br>
#include <memory><br>
struct base { virtual ~base(); };<br>
struct derived : base { };<br>
std::unique_ptr<base> f() {<br>
std::unique_ptr<derived> d;<br>
return d;<br>
}<br>
<br>
That shows whether the compiler's treating the return of a temporary as movable, even when the types aren't an exact match.<br>
<br>
Clang 3.5 does not support this conversion: <a href="https://godbolt.org/z/5nsWM8" target="_blank">https://godbolt.org/z/5nsWM8</a><br>
GCC 5.1 does support it: <a href="https://godbolt.org/z/cvd3d6" target="_blank">https://godbolt.org/z/cvd3d6</a><br>
& I'm not sure which MSVC version on godbolt would be "MSVC 2017" that the LLVM docs refer to.<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<div></div>
<div><br>
</div>
<div>If I understand the produced output correctly, then results are:</div>
<div><br>
</div>
<div>gcc 7.5: creates a copy.</div>
<div>gcc 8.1: uses move.</div>
<div><br>
</div>
<div>clang < 6.0: doesn't compile.</div>
</div>
</blockquote>
<div><br>
That's interesting - I wonder if LLVM's documentation is out of date, which claims the minimum required Clang is 3.5: <a href="https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library" target="_blank">https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library</a><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<div>clang >= 6.0: uses move.</div>
<div><br>
</div>
<div>MSVS: was unable to compile, complains about "llvm/Support/Error.h" header.</div>
<div>I am using MSVS 2017 locally and it calls move constructor of Expected<> though,</div>
<div>so I think all MSVS >= 2017 (at least) should be fine.<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>May be something to do with which compiler the llvm library provided by godbolt is compiled with? which might make the above results not quite right (& why testing with the non-llvm-specific example might be clearer)<br>
<br>
Looks like we would need to bump the minimum Clang up from 3.5 to at least 3.9 to allow returns with implicit moves that include conversions.<br>
- Dave <br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<div></div>
<p><br>
</p>
<p><br>
</p>
<div id="gmail-m_-7322763380935641288gmail-m_2002668242944554553gmail-m_7504072726545848816Signature">
<div name="divtagdefaultwrapper">
<div><font size="2">
<div>Best regards,<br>
George | Developer | <span style="background-color:rgb(255,255,255);color:rgb(33,33,33);font-family:Calibri,sans-serif;font-size:13.3333px">Access Softek, Inc</span></div>
</font></div>
</div>
</div>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7322763380935641288gmail-m_2002668242944554553gmail-m_7504072726545848816divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> Alexander Shaposhnikov <<a href="mailto:alexander.v.shaposhnikov@gmail.com" target="_blank">alexander.v.shaposhnikov@gmail.com</a>><br>
<b>Отправлено:</b> 28 сентября 2020 г. 22:46<br>
<b>Кому:</b> David Blaikie<br>
<b>Копия:</b> Richard Smith; llvm-dev; Lang Hames; George Rimar; James Henderson;
<a href="mailto:avl.lapshin@gmail.com" target="_blank">avl.lapshin@gmail.com</a><br>
<b>Тема:</b> [EXTERNAL] Re: [llvm-dev] preferred way to return expected values</font>
<div> </div>
</div>
<div>
<div style="font-size:9pt;font-family:Calibri,sans-serif">
<h3 style="background-color:rgb(255,255,255);font-size:10pt;border:1px dotted rgb(0,51,51);padding:0.8em">
<span style="color:rgb(255,102,0)">CAUTION:<strong> </strong></span>This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. If you suspect potential phishing
or spam email, report it to <a href="mailto:ReportSpam@accesssoftek.com" target="_blank">ReportSpam@accesssoftek.com</a></h3>
</div>
<div>
<div dir="ltr">Many thanks for the reply,
<div>right, this is what the discussion is about.</div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Sep 28, 2020 at 10:57 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">To clarify, this is a discussion around whether given some move-only type X, implicitly convertible to Y and the code "Y func() { X x; return x; }" is that valid in LLVM? (and, as a corollary, if the type isn't move-only, is that code efficient
(does it move rather than copying) - as in the vector example given)<br>
<br>
I /believe/ the answer is that it is not valid. I think the set of compilers supported includes those that do not implement this rule. (either due to the language version we compile with, or due to it being a DR that some supported compiler versions do not
implement). But that's just my rough guess.</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sat, Sep 26, 2020 at 3:17 PM Alexander Shaposhnikov via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Hello everyone!
<div>
<div>
<div>It looks like in the LLVM codebase (including subprojects) there are some inconsistencies <br>
<div>in how values are returned from functions with the following (or similar) signature:</div>
<div> Expected<std::vector<int>> createVector() {</div>
<div> std::vector<int> V;</div>
<div> ... </div>
<div> }</div>
<div>It would be interesting to find out your opinion on this.</div>
<div>After some investigation I have found <a href="https://reviews.llvm.org/D70963" target="_blank">https://reviews.llvm.org/D70963</a> and
<a href="https://reviews.llvm.org/D43322" target="_blank">https://reviews.llvm.org/D43322</a> which have some additional context regarding </div>
</div>
<div>the problem. The aforementioned diffs (and the comments on them) contain a lot of</div>
</div>
</div>
<div>details and the history of the problem (whether one should use the cast or not).</div>
<div>If I am not mistaken a part of the problem is that compilers' behaviors have changed over time, and e.g. the latest versions would use a move constructor while the older ones could use a copy constructor. So the question is where we stand at the moment
/ what is the recommended approach for the new code.</div>
<div><br>
</div>
<div>Many thanks in advance,</div>
<div>Alexander Shaposhnikov</div>
<div><br>
</div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote></div>