https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77376
Bug ID: 77376 Summary: GCC segfaults/returns bogus error (depending on version) when calling a member function from a generic lambda with a captured this without using "this->" explicitly. Product: gcc Version: unknown Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tinab at hush dot ai Target Milestone: --- GCC segfaults/returns bogus error (depending on version) when calling a member function from a generic lambda with a captured this without using "this->" explicitly. Seems to affect all versions of GCC with different results. On 5.4.0 a bogus error is returned: error: cannot call member function ‘...’ without object On other versions of GCC a segmentation fault occurs (up to and including GCC 7.0.0). This bug only occurs when a member function is called without "this->" being specified from the generic lambda, using "this->" explicitly resolves the problem. Example (from http://coliru.stacked-crooked.com/a/2a41c21343437d9c) =================================================================== g++ -std=c++14 -O2 -Wall -pedantic -pthread main.cpp && ./a.out main.cpp: In lambda function: main.cpp:13:10: internal compiler error: Segmentation fault thing(asdf, foo); Test case ========= #include <iostream> #include <string> #include <vector> struct Foo { void test(); void thing(void* a1, std::string a2); }; void Foo::test() { auto foo = "gfdgfd"; auto l = [&](auto asdf) { thing(asdf, foo); }; l(nullptr); } void Foo::thing(void* a1, std::string a2) { } int main() { }