public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vimal78 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/42741] New: core dump in recursive lambda function Date: Thu, 14 Jan 2010 01:57:00 -0000 [thread overview] Message-ID: <bug-42741-18668@http.gcc.gnu.org/bugzilla/> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 2712 bytes --] i am new to c++ lambda, and trying to use it. Please excuse me if my bug reports are invalid. here is something i wished would work, but doesn't. auto sum = [&term,&next,&sum](int a, int b)mutable ->int { if(a>b) return 0; else return term(a) + sum(next(a),b); }; It gives compilation error: vimal@linux-718q:~/Study/09C++/c++0x/lambda> g++ -g -std=c++0x sum.cpp sum.cpp: In lambda function: sum.cpp:13:36: error: ((<lambda(int, int)>*)this)-><lambda(int, int)>::sum cannot be used as a function Then i changed the recursive lambda as follows: std::function<int(int,int)> sum = [&term,&next,&sum](int a, int b)->int { if(a>b) return 0; else return term(a) + sum(next(a),b); }; this seems to compile but gives a core dump. the gdb report is: vimal@linux-718q:~/Study/09C++/c++0x/lambda> gdb a.out GNU gdb (GDB) SUSE (6.8.91.20090930-2.4) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i586-suse-linux". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/vimal/Study/09C++/c++0x/lambda/a.out...done. (gdb) run Starting program: /home/vimal/Study/09C++/c++0x/lambda/a.out Missing separate debuginfo for /lib/ld-linux.so.2 Try: zypper install -C "debuginfo(build-id)=d7706cbaa0ca09319cb645eac789cb8399078797" Missing separate debuginfo for /lib/libm.so.6 Try: zypper install -C "debuginfo(build-id)=a488c775caa0433cb23f9764d683150f40872ef1" Missing separate debuginfo for /lib/libc.so.6 Try: zypper install -C "debuginfo(build-id)=ee302691046515fe3766ae3b7d47afd3e3a8d063" Program received signal SIGSEGV, Segmentation fault. 0x0804889b in _Base_manager<<lambda(int, int)> >::_M_get_pointer(const std::_Any_data &) (__source=...) at /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/functional:1569 1569 /* have stored a pointer */ : __source._M_access<_Functor*>(); (gdb) -- Summary: core dump in recursive lambda function Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: vimal78 at gmail dot com GCC build triplet: version 4.5.0 20091231 (experimental) GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42741
next reply other threads:[~2010-01-14 1:57 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-01-14 1:57 vimal78 at gmail dot com [this message] 2010-01-14 2:00 ` [Bug c++/42741] c++0x: " vimal78 at gmail dot com 2010-01-14 2:00 ` vimal78 at gmail dot com 2010-01-14 2:01 ` vimal78 at gmail dot com 2010-01-14 2:01 ` vimal78 at gmail dot com 2010-01-14 21:42 ` [Bug c++/42741] [c++0x] " vimal78 at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-42741-18668@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).