https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86859
Baptiste Parsy <baptiste.parsy at epita dot fr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |baptiste.parsy at epita dot fr --- Comment #1 from Baptiste Parsy <baptiste.parsy at epita dot fr> --- I get a similar issue. The following code compiles with clang 9.0.1 but fails with gcc 9.3.0: #include <functional> #include <iostream> template<class, class = std::void_t<> > struct needs_unapply : std::true_type { }; template<class T> struct needs_unapply<T, std::void_t<decltype(std::declval<T>()())>> : std::false_type { }; template<typename F> auto curry(F&& f) { if constexpr (needs_unapply<decltype(f)>::value) { return [=](auto&& ...x) { return curry( [=](auto&& ...xs) -> decltype(f(x..., xs...)) { return f(x..., xs...); } ); }; } else { return f(); } } int main() { auto f = [](auto a, auto b, auto c, auto d, auto e) { return a * b * c * d * e; }; std::cout << curry(f)(1, 2)(3)(4, 5); }