public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42741]  New: core dump in recursive lambda function
@ 2010-01-14  1:57 vimal78 at gmail dot com
  2010-01-14  2:00 ` [Bug c++/42741] c++0x: " vimal78 at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vimal78 at gmail dot com @ 2010-01-14  1:57 UTC (permalink / raw)
  To: gcc-bugs

[-- 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/42741] c++0x: core dump in recursive lambda function
  2010-01-14  1:57 [Bug c++/42741] New: core dump in recursive lambda function vimal78 at gmail dot com
@ 2010-01-14  2:00 ` vimal78 at gmail dot com
  2010-01-14  2:00 ` vimal78 at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: vimal78 at gmail dot com @ 2010-01-14  2:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from vimal78 at gmail dot com  2010-01-14 01:59 -------
the capture list refers to these lambda functions:

auto term = [](int a)->int{return a*a;};
auto next = [](int a)->int{return a++;};

sorry i didn't put this along earlier.


-- 

vimal78 at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|core dump in recursive      |c++0x: core dump in
                   |lambda function             |recursive lambda function


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42741


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/42741] c++0x: core dump in recursive lambda function
  2010-01-14  1:57 [Bug c++/42741] New: core dump in recursive lambda function vimal78 at gmail dot com
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: vimal78 at gmail dot com @ 2010-01-14  2:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from vimal78 at gmail dot com  2010-01-14 02:00 -------
Created an attachment (id=19592)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19592&action=view)
source file


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42741


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/42741] c++0x: core dump in recursive lambda function
  2010-01-14  1:57 [Bug c++/42741] New: core dump in recursive lambda function vimal78 at gmail dot com
  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
  4 siblings, 0 replies; 6+ messages in thread
From: vimal78 at gmail dot com @ 2010-01-14  2:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from vimal78 at gmail dot com  2010-01-14 02:01 -------
Created an attachment (id=19593)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19593&action=view)
generated file


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42741


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/42741] c++0x: core dump in recursive lambda function
  2010-01-14  1:57 [Bug c++/42741] New: core dump in recursive lambda function vimal78 at gmail dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: vimal78 at gmail dot com @ 2010-01-14  2:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from vimal78 at gmail dot com  2010-01-14 02:01 -------
Created an attachment (id=19594)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19594&action=view)
generated file


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42741


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/42741] [c++0x] core dump in recursive lambda function
  2010-01-14  1:57 [Bug c++/42741] New: core dump in recursive lambda function vimal78 at gmail dot com
                   ` (3 preceding siblings ...)
  2010-01-14  2:01 ` vimal78 at gmail dot com
@ 2010-01-14 21:42 ` vimal78 at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: vimal78 at gmail dot com @ 2010-01-14 21:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from vimal78 at gmail dot com  2010-01-14 21:42 -------
i am sorry, this is not a defect.


-- 

vimal78 at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42741


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-14 21:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-14  1:57 [Bug c++/42741] New: core dump in recursive lambda function vimal78 at gmail dot com
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

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).