https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71095
Bug ID: 71095 Summary: Problem with captureless generic lambda and calling function object with arguments passed by reference Product: gcc Version: 6.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: karol.wozniak at email dot com Target Milestone: --- #include <utility> struct do_some_stuff_by_ref { template <typename... T> int operator()(T &...) const { return 42; }; }; int main() { { // compiles both // g++-5 prog.cc -std=c++14 // g++-6 prog.cc -std=c++14 do_some_stuff_by_ref callable{}; int a = 0; [callable](auto &&... x) { return callable(std::forward<decltype(x)>(x)...); }(a); } { // compiles both // g++-5 prog.cc -std=c++14 // g++-6 prog.cc -std=c++14 do_some_stuff_by_ref ignore_me{}; int a = 0; [ignore_me](auto &&... x) { (void)ignore_me; do_some_stuff_by_ref callable{}; return callable(std::forward<decltype(x)>(x)...); }(a); } { // compiles // g++-5 prog.cc -std=c++14 // fails to compile // g++-6 prog.cc -std=c++14 // prog.cc:40:22: error: no match for call to ‘(do_some_stuff_by_ref) (int)’ // return callable(std::forward<decltype(x)>(x)...); // ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int a = 0; [](auto &&... x) { do_some_stuff_by_ref callable{}; return callable(std::forward<decltype(x)>(x)...); }(a); } return 0; } // $ g++-5 --version // g++-5 (Debian 5.3.1-17) 5.3.1 20160429 // // $ g++-6 --version // g++-6 (Debian 6.1.1-1) 6.1.1 20160430