https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111602
--- Comment #2 from Ed Catmur <ed at catmur dot uk> --- (In reply to Andrew Pinski from comment #1) > The local type of f() is not needed. Thanks! I was confused since the local type is required in this similar example: template<class> struct P { static constexpr bool value = true; }; template<class T> constexpr bool P<T>::value; template<bool> struct E {}; struct F { template<class T, class = E<P<T>::value>> F(T) {} }; template<class> struct C { C(F = []{}) {} }; auto f() { struct T {} t; return t; } template<class T> decltype(T()) g() { return T(); } int main() { g<C<decltype(f)>>(); }