http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710
Bug #: 55710 Summary: [C++11] Linkage errors with lambdas Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: daniel.krueg...@googlemail.com The following program compiled with gcc 4.8.0 20121209 (experimental) and compiled with flags -Wall -std=c++11 -pedantic //---------------- template <class T> struct X { static void (*code) (); }; template <class T> void (*X<T>::code) () = []{}; // Line 7 struct Y { void (*code) () = []{} ; // Line 10 void operator()() { code(); } }; int main () { X<int>::code(); Y()(); } //---------------- gives two linkage errors: "|In function `Y::code::{lambda()#1}::operator void (*)()() const':| 10|undefined reference to `Y::code::{lambda()#1}::_FUN()'| |In function `X<int>::code::{lambda()#1}::operator void (*)()() const':| 7|undefined reference to `X<int>::code::{lambda()#1}::_FUN()'| " for the functions that should be defined for the corresponding uncaptured lambda expressions. It should be noted, that struct Z { static void (*code) (); }; void (*Z::code) () = []{}; int main () { Z::code(); } doesn't cause a similar linkage error, though.