This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51494] New: Legal program rejection - capturing "this" when using static method inside lambda
- From: "ulidtko at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 10 Dec 2011 05:51:57 +0000
- Subject: [Bug c++/51494] New: Legal program rejection - capturing "this" when using static method inside lambda
- Auto-submitted: auto-generated
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.