https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77825
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2016-10-05 Known to work| |5.4.0, 6.2.0 Summary|return type deduction |[7 Regression] return type |regression in 7.0 |deduction regression in | |C++17 mode Ever confirmed|0 |1 Known to fail| |7.0 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- template<typename T> struct decay { using type = T; }; template<typename T> struct decay<T&> { using type = T; }; template<typename T> struct decay<T&&> { using type = T; }; template<typename T> using decay_t = typename decay<T>::type; template<typename _Tp> constexpr _Tp&& forward(decay_t<_Tp>& __t) noexcept { return static_cast<_Tp&&>(__t); } template <class F> struct y_combinator { F f; template <class... Args> decltype(auto) operator()(Args&&... args) const { return f(*this, forward<Args>(args)...); } }; template <class F> y_combinator<decay_t<F>> make_y_combinator(F&& f) { return {forward<F>(f)}; } int main() { auto factorial = make_y_combinator([](auto fact, int n) -> int { if (n == 0) return 1; else return n * fact(n - 1); }); factorial(5); } It compiles OK as C++14 but not as C++1z.