<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Feb 4, 2015, at 9:36 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 4, 2015 at 6:38 PM, John McCall <span dir="ltr" class=""><<a href="mailto:rjmccall@apple.com" target="_blank" class="">rjmccall@apple.com</a>></span> wrote:<br class=""><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"><span class="">On Jun 5, 2014, at 4:17 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:<br class="">> John: any chance we could get the ABI document updated with these? (<a href="http://sourcerytools.com/pipermail/cxx-abi-dev/2012-January/000024.html" target="_blank" class="">http://sourcerytools.com/pipermail/cxx-abi-dev/2012-January/000024.html</a>)<br class="">
<br class="">
</span>After much delay, added.  We don’t seem to get this right, though, at least not when the destination type isn’t dependent:<br class="">
<br class="">
template <class T, class U> T fst(T, U);<br class="">
struct A {<br class="">
  int x[3];<br class="">
};<br class="">
template <class T> decltype(fst(A{1,2},T())) foo(T t) {}<br class="">
<br class="">
int main() {<br class="">
  foo(1);<br class="">
}<br class="">
<br class="">
We produce:<br class="">
  _Z3fooIiEDTcl3fstcv1AililLi1ELi2EEEcvT__EEES1_<br class="">
It should be:<br class="">
  _Z3fooIiEDTcl3fsttl1ALi1ELi2EcvT__EEES1_<br class=""></blockquote><div class=""><br class=""></div><div class="">There are quite a few bugs conspiring to give that result :( Our AST is also poorly-suited to this mangling, because the braces are not considered to be part of the functional cast itself; they're part of its subexpression.</div><div class=""><br class=""></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">
If you parenthesize the argument to A:<br class="">
  template <class T> decltype(fst(A({1,2}),T())) foo(T t) {}<br class="">
We produce:<br class="">
  _Z3fooIiEDTcl3fstcv1AcvS0_ililLi1ELi2EEEcvT__EEES1_<br class="">
It should be:<br class="">
  _Z3fooIiEDTcl3fstcv1AliLi1ELi2EcvT__EEES1_<br class=""></blockquote><div class=""><br class=""></div><div class="">Somewhat related, we also get this wrong:</div><div class=""><br class=""></div><div class="">struct X { X(int); };</div><div class="">int f(X);</div><div class="">template<typename T> void f(decltype(f(0), T())) { f(0); }</div><div class="">void g() { f<int>(0); }</div><div class=""><br class=""></div><div class="">... because we explicitly mangle the implicit conversion from int to X. I see</div><div class=""><br class=""></div><div class="">_Z1fIiEvDTcmcl1fLi0EEcvT__EE from EDG<br class=""></div><div class="">_Z1fIiEvDTcmclL_Z1f1XELi0EEcvT__EE from GCC<br class=""></div><div class="">_Z1fIiEvDTcmclL_Z1f1XEcvS0_cvS0_Li0EEcvT__EE from Clang</div></div></div></div></div></blockquote><div><br class=""></div>Ugh, that’s awful.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">I think GCC and Clang are right to use the resolved name L_Z1f1XE rather than the unresolved name 1f here, and GCC's mangling is right overall. Do you agree?</div></div></div></div>
</div></blockquote></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra">As an aside: if we have a fully-resolved call in an instantiation-dependent expression, should we really be putting any used default arguments into the mangling?</div></div></blockquote></div><br class=""></div><div class="">I feel like both of these points need to be asked on the cxx-abi-dev.  I definitely don’t think we should be mangling default arguments, but I’m not sure that resolving ‘f’ here is really consistent with the general dictate to follow the syntactic tree.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra">All of the above fixed in r228274. I'm not really very happy with our AST representation here; we've overloaded CXXConstructExpr to mean too many different syntactic things that it's hard to reconstruct the right mangling.</div></div></blockquote><div class=""><br class=""></div>The rule used to be that a “bare" CXXConstructExpr — neither a specific subclass nor the implementation of a cast — was always implicit, and that there were subclasses which provided additional syntactic information.  I think it would make sense to have a dedicated subclass for the truly implicit case as well.  The implicit case is always a constructor conversion or copy-construction, right?</div><div class=""><br class=""></div><div class="">John.</div></body></html>