Description of problem: This is related to bug 982324 and it appears to be a regression. The testcase from the bug above: --- #include <functional> class A { typedef std::function<int()> Func; Func f_; public: template<class T = Func> A(const T& f = []() { return 0; }) : f_(f) {} }; int main(int argc, char* argv[]) { A a; } --- I cannot find anything wrong with it, if I put function pointer or handmade functor instead of lambda as a default parameter, it seems to work. Version-Release number of selected component (if applicable): devtoolset-3-gcc-c++-4.9.1-10 Steps to Reproduce: 1. g++ -g -std=c++11 test.h Actual results: test.h:7:46: error: default argument for template parameter for class enclosing ‘A::<lambda>’ template<class T = Func> A(const T& f = []() { return 0; }) : f_(f) {} ^ test.h: In function ‘int main(int, char**)’: test.h:11:5: error: no matching function for call to ‘A::A()’ A a; ^ test.h:11:5: note: candidates are: test.h:7:28: note: template<class T> A::A(const T&) template<class T = Func> A(const T& f = []() { return 0; }) : f_(f) {} ^ test.h:7:28: note: template argument deduction/substitution failed: test.h:11:5: note: couldn't deduce template parameter ‘T’ A a; ^ test.h:3:7: note: A::A(const A&) class A { ^ test.h:3:7: note: candidate expects 1 argument, 0 provided test.h:3:7: note: A::A(A&&) test.h:3:7: note: candidate expects 1 argument, 0 provided Expected results: it compiles
Trunk accepts this. I'm going to bisect this one.
Fixed by r215477 aka PR c++/62219 fix. The fix looks easy and has been backported to 4.9 branch; it basically only allows using LAMBDA_FUNCTION_P as a default template argument.
Fixed.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2015-0880.html