mangling for instantiation-dependent non-type template parameter types · Issue #20 · itanium-cxx-abi/cxx-abi (original) (raw)
The mangling for a function template does not include the instantiation-dependent portions of non-type template parameters (including such things transitively within template template parameters). This is becoming increasingly important as people try to write things like:
template<typename T, std::void_t<typename T::x>* = nullptr> void func() {}
template<typename T, std::void_t<typename T::y>* = nullptr> void func() {}
(std::void_t<T>
is void
for all T
. It's not obvious whether it's supposed to be a dependent type, but the above cases are at least instantiation-dependent types.)
For a type T
providing both a nested x
and a nested y
, we will mangle instantiations of the two possible func<T>
s the same, despite them being distinct templates.
Including the (pre-substitution) types of non-type template parameters in the mangling (if they're instantiation-dependent) seems like the obvious fix, but it would likely result in an ABI break for a significant amount of existing code.
We should probably at least fix this for ABI v2.