Is template function with `auto` template type the same as with T-type in C++20?

Viewed 44

Please consider this C++20 program:

template<typename T>
void foo( T );

void foo( auto ) {}

template<int>
void foo( int ) {}

int main()
{
    foo<int>( 0 );
}

It is accepted by Clang and rejected by GCC with the error:

error: call of overloaded 'foo(int)' is ambiguous

https://gcc.godbolt.org/z/fv73WdKda

Apparently Clang thinks that template<typename T> void foo( T ); and void foo( auto ); are the declarations of the same template function, and GCC thinks that these are two distinct template functions. Which of the compilers is right according to C++20?

0 Answers
Related