https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85764
Bug ID: 85764 Summary: bogus ‘this’ was not captured for this lambda function error Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sebasti at nullri dot ch Target Milestone: --- template<typename Key> class trie { static void for_each(int & f, trie const & n, Key & prefix) { [&](trie const & c) { for_each(f, c, prefix); }; } void for_each(int & f) const { } }; --- $ g++ foo.h foo.h: In lambda function: foo.h:5:32: error: ‘this’ was not captured for this lambda function for_each(f, c, prefix); Works fine in 7.3. Also works after removing the lambda (i.e. the overload is resolved correctly) or the template.