http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51494

             Bug #: 51494
           Summary: Legal program rejection - capturing "this" when using
                    static method inside lambda
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ulid...@gmail.com


Consider the following source code:

struct A
{
    static void f() {}

    void foo()
    {
        [] () { f(); };
    }
};


GCC 4.6.1 produces the following error message when compiling it:
test.cpp: In lambda function:
test.cpp:7:27: error: ‘this’ was not captured for this lambda function

However, the member function f is static and it's call doesn't use 'this';
therefore the lambda need not to capture 'this'. The code shall compile.

Reply via email to