http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54947
Bug #: 54947 Summary: [4.7/4.8 Regression] [C++11] lambda cannot capture-by-copy inside braced-init-list Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: r...@gcc.gnu.org Blocks: 54367 struct X { template<typename L> X(L) { } }; template<typename A> void test() { int i = 0; A a_ok_1( [=] { return i; } ); // OK A a_ok_2( [i] { return i; } ); // OK A a_err_1{ [i] { return i; } }; // error A a_err_2{ [=] { return i; } }; // error } int main() { test<X>(); } lam.cc:17:17: error: the value of ‘i’ is not usable in a constant expression A a_err_1{ [i] { return i; } }; // error ^ lam.cc:12:9: note: ‘int i’ is not const int i = 0; ^ lam.cc:18:17: error: expression ‘<erroneous-expression> = <erroneous-expression>’ is not a constant-expression A a_err_2{ [=] { return i; } }; // error ^ There's no error when using direct-initialization, only list-initialization. No error if test() is not a function template. Works fine with 4.6 and clang++