Why does the following code compile with GCC but not with Clang? Who is right and why?
class TF
{
private:
struct S
{
};
template <typename T> friend void F(T x, S s, int v = 5);
};
template <typename T>
void F(T x, TF::S s, int v)
{
}
I get following error with clang++:
error: friend declaration specifying a default argument must be a definition
template <typename T> friend void F(T x, S s, int v = 5);
^
error: friend declaration specifying a default argument must be the only declaration
void F(T x, TF::S s, int v)
^
note: previous declaration is here
template <typename T> friend void F(T x, S s, int v = 5);
GCC version: g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: clang version 6.0.0-1ubuntu2
How do I resolve this?