Consider the following example:
struct A {
using type = int;
};
template <typename T>
using B = A;
template <typename T>
typename B<T>::type f() { return {}; }
template B<int>::type f<int>();
Clang generates symbol named int f<int>()
while GCC generates B::type f<int>()
for the instantiation: https://godbolt.org/z/MCCza4
Why don't the compilers agree and shouldn't GCC also resolve B::type
to int
?
This is a known C++ CWG (Core Working Group) issue: https://wg21.cmeerw.net/cwg/issue2037, quoting Richard Smith:
On the one hand, the alias template can introduce SFINAE conditions, so it should be instantiation-dependent and mangled. On the other hand, the language rules permit this template to be redeclared using the result of expanding the alias template, so mangling it can't be correct.