https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461
--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #7) > Reduced testcase: Interestingly Clang also rejects this testcase, so I'm not sure if we were correct to accept it previously. Here's a more reduced testcase that seems clearly valid: template <typename T> T foo (); template <typename> struct A { }; template <typename T> struct B { template <typename U, typename = A<decltype (foo<T>() (U()))>> static void bar(U); }; int main() { B<int> b; B<void(*)(int)>::bar(0); } <stdin>: In function ‘int main()’: <stdin>:12:23: error: no matching function for call to ‘B<void (*)(int)>::bar(int)’ <stdin>:7:15: note: candidate: ‘template<class U, class> static void B<T>::bar(U) [with <template-parameter-2-2> = U; T = void (*)(int)]’ <stdin>:7:15: note: template argument deduction/substitution failed: <stdin>:6:54: error: expression cannot be used as a function If we remove the line #1 then this bogus error disappears.