[Bug c++/54995] Converting lambda to C-style functions when there is template
i.nixman at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Oct 20 07:15:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54995
--- Comment #1 from niXman <i.nixman at gmail dot com> 2012-10-20 07:15:28 UTC ---
> App crash:
> http://liveworkspace.org/code/3d5e51c9059ea4f37ce2d0d23739d374
More detailed output.
source:
#include <stdio.h>
typedef void(*void_func)();
void foo(void_func f) {
f();
}
class C {
public:
template<typename F>
void bar(F f) {
auto func = [f, this] {
f();
printf("%d!!!\n", k);
};
foo(func);
}
private:
int k = 10;
};
int main() {
printf("%s\n", "ping1");
auto func = [] {
printf("called\n");
};
printf("%s\n", "ping2");
C().bar(func);
printf("%s\n", "ping3");
}
run:
$ g++-4.7.2 -std=c++11 ice.cpp -oice && ./ice
ping1
ping2
called
Segmentation fault (core dumped)
More information about the Gcc-bugs
mailing list