http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Bug #: 55015 Summary: Lambda functions not found at link time when declared in an inline function Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: julien.nit...@m4tp.org Hi all, Following this stackoverflow question http://stackoverflow.com/questions/13003941/lambda-not-found-when-defined-in-an-inline-function-in-g-4-7, I was directed here to report a bug. I have tried to find similar bugs but haven't. Lambdas are not handled properly when declared inside inline functions (or so it seems). Here is a LWS link that demonstrates the error: http://liveworkspace.org/code/35374b3c9b0d40e8ccc0819eb44d7f9e In case the link disappears, here the source: #include <stdexcept> #include <string> #include <boost/algorithm/string.hpp> using std::string; typedef bool (*FieldComparer)(const std::string&, const std::string&); inline FieldComparer GetComparer(const std::string& query, string& separator) { if (query.find('=') != std::string::npos) { separator = "="; return [](const string& s1, const string& s2) { return s1 == s2; }; } else if (query.find('^') != string::npos) { separator = "^"; return [](const string& s1, const string& s2) { return boost::starts_with(s1, s2); }; } else if (query.find('*') != string::npos) { separator = "*"; return [](const string& s1, const string& s2) { return boost::contains(s1, s2); }; } else if (query.find('!') != string::npos) { separator = "!"; return [](const string& s1, const string& s2) { return s1 != s2; }; } else throw std::invalid_argument("Search: could not find operator in query string."); } int main() { std::string sep; auto comp = GetComparer( "=", sep ); } Many thanks,