[Bug c++/51494] Legal program rejection - capturing "this" when using static method inside lambda
kpx1894 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Dec 7 15:18:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51494
kpx1894 <kpx1894 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kpx1894 at gmail dot com
--- Comment #7 from kpx1894 <kpx1894 at gmail dot com> 2012-12-07 15:18:03 UTC ---
This bug is still present in GCC 4.7.2. There are cases where capturing "this"
(as a workaround) is not possible:
----------
#include <iostream>
struct Test
{
void (*get())()
{
return [](){ Test::sf(); };
}
static void sf()
{
std::cout << "Test::sf" << std::endl;
}
};
int main()
{
Test test;
auto f = test.get();
(*f)();
}
----------
More information about the Gcc-bugs
mailing list