The following program
template<int>
struct R{};
struct S
{
template<typename T>
auto f(T t) -> R<sizeof(t)>;
};
template<typename T>
auto S::f(T t) -> R<sizeof(t)> {}
compiles with Clang, but GCC 10.2 gives an error for the definition of f
error: no declaration matches 'R<sizeof (t)> S::f(T)'
This looks like a GCC bug, especially since GCC trunk currently gives an ICE
internal compiler error: canonical types differ for identical types 'R<sizeof (t)>' and 'R<sizeof (t)>'
Also, GCC compiles the program when the return type in both the declaration and the definition is changed to R<sizeof (T)>.
Is the program valid?
Here's the demo.