<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">The 4<sup>th</sup> constructor takes a (unique) pointer, not a reference, but you pass an rvalue reference.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If you really need an unique pointer, you can make one with std::make_unique.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:Consolas">-- </span>
<span style="font-size:9.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">Krzysztof Parzyszek 
<a href="mailto:kparzysz@quicinc.com"><span style="color:#0563C1">kparzysz@quicinc.com</span></a>   AI tools development<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> <b>On Behalf Of
</b>Paul C. Anagnostopoulos via llvm-dev<br>
<b>Sent:</b> Tuesday, March 30, 2021 7:03 PM<br>
<b>To:</b> LLVM dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> [EXT] [llvm-dev] C++ compiler error I do not understand<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p><span style="font-family:"Helvetica",sans-serif">I have the following situation with which I could use some enlightenment. As usual, the context is TableGen.</span><o:p></o:p></p>
<p><span style="font-family:"Helvetica",sans-serif">in class Record:</span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p><tt><span style="font-size:10.0pt">public:</span></tt><span style="font-size:10.0pt;font-family:"Courier New""><br>
<tt>  using AssertionTuple = std::tuple<SMLoc, Init *, Init *>;</tt><br>
<tt>...</tt><br>
<tt>  SmallVector<AssertionTuple, 0> Assertions;</tt></span><o:p></o:p></p>
</blockquote>
<p>then there exists:<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p><tt><span style="font-size:10.0pt">  struct RecordsEntry {</span></tt><span style="font-size:10.0pt;font-family:"Courier New""><br>
<tt>    std::unique_ptr<Record> Rec;</tt><br>
<tt>    std::unique_ptr<ForeachLoop> Loop;</tt><br>
<tt>    std::unique_ptr<Record::AssertionTuple> Assertion;</tt><br>
<br>
<tt>    void dump() const;</tt><br>
<br>
<tt>    RecordsEntry() {}</tt><br>
<tt>    RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}</tt><br>
<tt>    RecordsEntry(std::unique_ptr<ForeachLoop> Loop)</tt><br>
<tt>      : Loop(std::move(Loop)) {}</tt><br>
<tt>    RecordsEntry(std::unique_ptr<Record::AssertionTuple> Assertion) // 4th constructor</tt><br>
<tt>      : Assertion(std::move(Assertion)) {}</tt><br>
<tt>  };</tt></span><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">...</span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">bool TGParser::addEntry(RecordsEntry E) { ...</span></tt><o:p></o:p></p>
</blockquote>
<p>Note that I expect to create a RecordsEntry by passing an AssertionTuple to addEntry and having the 4th constructor do the trick. The other three constructors all work fine. However, when I do this:<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p><tt><span style="font-size:10.0pt">    Record::AssertionTuple tuple = std::make_tuple(ConditionLoc, Condition, Message);</span></tt><span style="font-size:10.0pt;font-family:"Courier New""><br>
<tt>    addEntry(std::move(tuple));</tt></span><o:p></o:p></p>
</blockquote>
<p>I get this:<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p><tt><span style="font-size:10.0pt">C:\LLVM\llvm-project\llvm\lib\TableGen\TGParser.cpp(3190): error C2664: 'bool llvm::TGParser::addEntry(llvm::RecordsEntry)': cannot convert argument 1 from 'llvm::Record::AssertionTuple' to 'llvm::RecordsEntry'</span></tt><span style="font-size:10.0pt;font-family:"Courier New""><br>
<tt>C:\LLVM\llvm-project\llvm\lib\TableGen\TGParser.cpp(3190): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called</tt><br>
<tt>C:\LLVM\llvm-project\llvm\lib\TableGen\TGParser.cpp(344): note: see declaration of 'llvm::TGParser::addEntry'</tt></span><o:p></o:p></p>
</blockquote>
<p>Ah, I guess I should show the definitions of the three arguments passed to make_tuple() above:<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p><tt><span style="font-size:10.0pt">  SMLoc ConditionLoc = Lex.getLoc();</span></tt><span style="font-size:10.0pt;font-family:"Courier New""><br>
<tt>  Init *Condition = ParseValue(CurRec);</tt><br>
<tt>  Init *Message = ParseValue(CurRec);</tt></span><o:p></o:p></p>
</blockquote>
<p>Since there is no complaint about making the tuple, I assume those three arguments have the correct type. The problem is the 4th RecordsEntry constructor, which cannot convert the addEntry argument 'std::move(tuple)' to a Record::AssertionTuple, even though
 that's exactly what it is.<o:p></o:p></p>
<p>P.S.: Regardless of what I learn here, I'm going to change the assertion tuple into a little struct, which should work fine as demonstrated by constructor 3 above.<o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt"><br>
<br>
</span><o:p></o:p></p>
</div>
</div>
</body>
</html>