[Bug libstdc++/77451] Cannot convert lambda [](auto&&...){} to std::function<void()>

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 13 20:03:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77451

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is a compiler bug not a library one:

int main()
{
  auto l = [](auto&&...) {};
  l();
}

l.cc: In function ‘int main()’:
l.cc:4:5: error: no match for call to ‘(main()::<lambda(auto:1&&, ...)>) ()’
   l();
     ^
l.cc:3:24: note: candidate: template<class auto:1> main()::<lambda(auto:1&&,
...)>::operator decltype (((const main()::<lambda(auto:1&&, ...)>*)((const
main()::<lambda(auto:1&&, ...)>*
const)0))->operator()(static_cast<auto:1&&>(<anonymous>))) (*)(auto:1&&, ...)()
const <deleted>
   auto l = [](auto&&...) {};
                        ^
l.cc:3:24: note:   template argument deduction/substitution failed:
l.cc:4:5: note:   candidate expects 1 argument, 0 provided
   l();
     ^
l.cc:3:24: note: candidate: template<class auto:1> main()::<lambda(auto:1&&,
...)>
   auto l = [](auto&&...) {};
                        ^
l.cc:3:24: note:   template argument deduction/substitution failed:
l.cc:4:5: note:   candidate expects 1 argument, 0 provided
   l();
     ^


It works fine if you call it as l(1) or l(1, 2).

Not a regression, it's failed the same way since generic lambdas were added to
4.9


More information about the Gcc-bugs mailing list