<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 22, 2014 at 3:58 AM, Jiangning Liu <span dir="ltr"><<a href="mailto:liujiangning1@gmail.com" target="_blank">liujiangning1@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">Hi,<br><br>I have a question about C++ name mangling.<div><br></div><div>For the following small program (I failed to get it further minimized), clang++ and g++ generate different symbols for function fin introduced by the last specialization statement.<br><br>clang++: AA<3>::aa BB::fin<3, AA>(AA const&)<br>g++: AA<3>::aa BB::fin<3, AA>(AA<3> const&)</div></div></blockquote><div><br></div><div>Demangled names are not useful when talking about mangling differences. The mangled names are:</div><div><br></div><div> _ZN2BB3finILi3E2AAEENT0_IXT_EE2aaERKS2_ (from clang)</div><div> _ZN2BB3finILi3E2AAEENT0_IXT_EE2aaERKS3_ (from gcc)<br></div><div><br></div><div>GCC's mangling appears to be correct here (modulo a bug in the ABI that gives a mangling to an empty <prefix>). S2_ refers to T0_ from the nested-name-specifier in the return type; S3_ refers to T0_IXT_EE, which is what we want in the parameter's type.</div><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"><div>If I change the return type of fin to be void, I can see the argument AA<3> can be correctly generated for clang++.<br><br>{code}<br><div>template <int dim> <br>class AA<br>{<br> template <class DH> struct Iter;<br><br> template <template <int> class DH><br> struct Iter<DH<3> ><br> { <br> typedef DH<3> AA_type;<br> }; <br><br> typedef Iter<AA<dim> > IteratorSelector;<br>public:<br> typedef typename IteratorSelector::AA_type aa;<br>};<br><br>class BB<br>{<br> template <int dim, template<int> class C><br> static typename C<dim>::aa fin (const C<dim> &container);<br><br> template <int dim><br> static void pp (const AA<dim>& dof)<br> { <br> typename AA<dim>::aa temp = fin (dof);<br> } <br>};<br><br>template void BB::pp<3> (const AA<3>&);<br></div><div>{code}</div><div><br></div><div>So anybody know why?</div><div><br></div><div>This problem will cause failure of linking object files generated by clang++ and g++ separately, and potentially introduce run-time bugs.<div><br></div><div>Thanks,</div><div>-Jiangning</div></div></div></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>