<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 12, 2010, at 10:55 AM, John McCall wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On Feb 27, 2010, at 12:06 AM, Enea Zaffanella wrote:<br><blockquote type="cite"><font class="Apple-style-span" color="#144FAE"><br></font></blockquote><blockquote type="cite">But then I get to the following case<br></blockquote><blockquote type="cite">    S s3 = S(3);<br></blockquote><blockquote type="cite">for which I get the following AST:<br></blockquote><blockquote type="cite">=============<br></blockquote><blockquote type="cite">  (DeclStmt 0x1d5f430 <line:8:3, col:14><br></blockquote><blockquote type="cite">    0x1d5f1f0 "struct S s3 =<br></blockquote><blockquote type="cite">      (ImplicitCastExpr 0x1d5f3f0 <col:10, col:13> 'struct S' <br></blockquote><blockquote type="cite"><ConstructorConversion><br></blockquote><blockquote type="cite">        (CXXConstructExpr 0x1d5f380 <col:10, col:13> 'struct S''void <br></blockquote><blockquote type="cite">(struct S const &)' elidable<br></blockquote><blockquote type="cite">          (ImplicitCastExpr 0x1d5f340 <col:10, col:13> 'struct S const' <br></blockquote><blockquote type="cite"><NoOp><br></blockquote><blockquote type="cite">            (CXXFunctionalCastExpr 0x1d5f300 <col:10, col:13> 'struct <br></blockquote><blockquote type="cite">S' functional cast to struct S<br></blockquote><blockquote type="cite">              (CXXConstructExpr 0x1d5f290 <col:10, col:12> 'struct <br></blockquote><blockquote type="cite">S''void (int)'<br></blockquote><blockquote type="cite">                (IntegerLiteral 0x1d5f250 <col:12> 'int' 3))))))"<br></blockquote><blockquote type="cite">=============<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Here there are two things that I do not understand.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">First, I cannot see why the result of the inner CXXConstructorExpr call <br></blockquote><blockquote type="cite">should be fed to a CXXFunctionalCastExpr. I may agree that the <br></blockquote><blockquote type="cite">initializer of s3 is a functional cast expression ... but then I would <br></blockquote><blockquote type="cite">expect that the argument of this functional cast is the integer literal, <br></blockquote><blockquote type="cite">not the struct S object returned by the constructor.<br></blockquote><blockquote type="cite">In other words, to my eyes, the presence of the functional cast should <br></blockquote><blockquote type="cite">exclude the presence of the inner constructor call, or vice versa.<br></blockquote><blockquote type="cite">Is my reasoning missing some important point?<br></blockquote><br>This is a strange representation, and it looks even stranger when the functional cast is actually invoking a user-defined conversion.  CodeGen aggressively elides the constructor calls (in most cases; I don't enough about that corner of the standard to know if it's missing legal elisions), so it's just an internal-representation issue rather than also being a performance issue.  Still, it's not a good representation, and if the elision optimization is disabled (which is a supported configuration, I think) it might mean we make too many copies.<br><br></div></blockquote><div><br></div>Actually, it's not that strange :)</div><div><br></div><div>The CXXFunctionalCastExpr is just the syntactical representation, and the inner CXXConstructExpr has all the constructor information - which constructor to call, default arguments etc.</div><div><br></div><div>Anders</div></body></html>