This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54995] Converting lambda to C-style functions when there is template
- From: "i.nixman at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 20 Oct 2012 07:15:28 +0000
- Subject: [Bug c++/54995] Converting lambda to C-style functions when there is template
- Auto-submitted: auto-generated
- References: <bug-54995-4@http.gcc.gnu.org/bugzilla/>
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)