Is the following code (live example) conformant to the C++20 specifications? And why or why not? Clang and GCC seem to be in disagreement as Clang 14.0.0 happily compiles the given example.
struct s {
template<typename T>
inline static auto f
= [](){ return T::template g<s>; };
};
struct t {
template<typename T>
inline static auto g
= [](){ return T::template f<t>; };
};
auto main() -> int {
s::f<t>();
}
The error produced by GCC 12.1:
<source>:4:36: required from 'auto s::f<t>'
<source>:14:8: required from here
<source>:10:36: error: use of 's::f<t>' before deduction of 'auto'
10 | = [](){ return T::template f<t>; };
| ~~~~~~~~~~~~^~~~
<source>:10:36: error: use of 's::f<t>' before deduction of 'auto'
Interestingly, when invoking the instantion of s::f, as in s::f<t>()();, Clang seems to give out completely.