New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mangling for placeholders for deduced class template specializations (CTAD) #109
Comments
It would be better if it were a substitution candidate, right? And that would only change mangling for this case, where we already have implementation disagreement? |
Well, the complete type will be a substitution candidate if the same deduced placeholder is used twice, so we will get some substitutions at least. But we won't treat the type If we choose to treat it as a substitution candidate, would we introduce two |
I think you're drawing a distinction that doesn't exist; template names are usually substitution candidates when they appear in later types, e.g. template <class> class A;
template <template <class> class T, class U> void foo() {}
template void foo<A, A<int>>(); // _Z3fooI1AS0_IiEEvv |
Your example certainly addresses half of my concern: it demonstrates that we'll use <substitution>s in one production ( Here's a situation that I think is a little more directly analogous, where we use the same name as both a type and a template: template<typename> struct U {};
struct T : U<int> {};
template<typename, template<typename> typename> struct X {};
template<typename T> void g(X<typename T::U, T::template U>) {}
void h() { g<T>(X<U<int>, U>()); } While Clang and GCC mangle this slightly differently, both agree that Nonetheless, I don't think there are any practical problems with allowing a substitution to be used in this specific case -- I don't think we can ever encounter a mangling collision due to this, even though (as noted above) the template/type duality of template names can lead to mangling collisions in other contexts. But I don't think it falls out from the "substitution represents a particular entity" model, because |
I don't think it's ever the rule that substitutions are production-specific. The rule is focused squarely on whether you're talking about the same entity. And the similarity of the two Am I missing something where placeholder types can be more complicated, e.g. where you infer arguments from multiple levels of type at once? My concrete suggestion is that we should just allow |
I don't think we should special-case
... with an explicit mention in 5.1.10 that such a placeholder is a substitution candidate for its deduced template and vice versa.
I don't think we do, because I don't think there's any context in which we can encounter |
Ah, sure. That works for me. |
substitutable for the deduced template. As agreed in itanium-cxx-abi/cxx-abi#109.
substitutable for the deduced template. As agreed in itanium-cxx-abi/cxx-abi#109.
Per itanium-cxx-abi/cxx-abi#109 mangle a C++17 CTAD placeholder as its template. gcc/cp/ChangeLog: * mangle.cc (write_type): Mangle placeholder as its template. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class4.C: Specify ABI v18. * g++.dg/cpp2a/nontype-class4a.C: New test.
Per itanium-cxx-abi/cxx-abi#109 mangle a C++17 CTAD placeholder as its template. gcc/cp/ChangeLog: * mangle.cc (write_type): Mangle placeholder as its template. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class4.C: Specify ABI v18. * g++.dg/cpp2a/nontype-class4a.C: New test.
Per itanium-cxx-abi/cxx-abi#109 mangle a C++17 CTAD placeholder as its template. gcc/cp/ChangeLog: * mangle.cc (write_type): Mangle placeholder as its template. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class4.C: Specify ABI v18. * g++.dg/cpp2a/nontype-class4a.C: New test.
Per itanium-cxx-abi/cxx-abi#109 mangle a C++17 CTAD placeholder as its template. gcc/cp/ChangeLog: * mangle.cc (write_type): Mangle placeholder as its template. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class4.C: Specify ABI v18. * g++.dg/cpp2a/nontype-class4a.C: New test.
Per itanium-cxx-abi/cxx-abi#109 mangle a C++17 CTAD placeholder as its template. gcc/cp/ChangeLog: * mangle.cc (write_type): Mangle placeholder as its template. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class4.C: Specify ABI v18. * g++.dg/cpp2a/nontype-class4a.C: New test.
Testcase:
GCC mangles this as:
_Z1fIiEvT_DTcvDafL0p_EN1N1AIiEE
That is:
f(T t, decltype(auto(t)), N::A<int>)
Clang trunk asserts; older Clangs mangle this as:
_Z1fIiEvT_DTcv1AfL0p_ENS1_IiEE
That is:
f(T t, decltype(A(t)), {subst for A}<int>)
ICC mangles this as:
_Z1fIiEvT_DTcvT18446744073709551614_fL0p_EN1N1AIiEE
That is:
f(T t, decltype(<template parameter 18446744073709551615>(t)), N::A<int>)
These are all different from each other and none of them is reasonable.
The natural way to mange such a placeholder type would seem to be as a <name>, where the final <unqualified-name> in a <nested-name> would be the template name. So the mangling for the above example would be:
_Z1fIiEvT_DTcvN1N1AEfL0p_ENS1_1AIiEE
. (Note that the <type> in the first parameter is not a substitution candidate for the <template-prefix> in the second.)(I'm not sure if this needs actual ABI updates or if this is just an implementation bug shared by every implementation; there don't seem to be any other natural choices for how to mangle this.)
The text was updated successfully, but these errors were encountered: