This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/51494] New: Legal program rejection - capturing "this" when using static method inside lambda


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: unassigned@gcc.gnu.org
        ReportedBy: ulidtko@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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]