[Bug c++/42737] New: c++0x: error returning a lambda function

2010-01-13 Thread vimal78 at gmail dot com
vi...@linux-718q:~/Study/09C++/c++0x/lambda> g++ return1.cpp -std=c++0x
return1.cpp: In function ‘int (* f())()’:
return1.cpp:6:25: internal compiler error: canonical types differ for identical
types int() and int()
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.



file: return1.cpp
=

auto f() ->int(*)(){
  auto m = [](){ return 0;};
  return m;
}

int main() {
  return 0;
}


-- 
   Summary: c++0x: error returning a 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: GNU C version 4.5.0 20091231 (experimental), GMP version
4.3.1,
  GCC host triplet: /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0
GCC target triplet: i686-pc-linux-gnu


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



[Bug c++/42737] c++0x: error returning a lambda function

2010-01-13 Thread vimal78 at gmail dot com


--- Comment #1 from vimal78 at gmail dot com  2010-01-13 22:32 ---
Created an attachment (id=19586)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19586&action=view)
c++ source file


-- 


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



[Bug c++/42737] c++0x: error returning a lambda function

2010-01-13 Thread vimal78 at gmail dot com


--- Comment #2 from vimal78 at gmail dot com  2010-01-13 22:33 ---
Created an attachment (id=19587)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19587&action=view)
generated file


-- 


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



[Bug c++/42737] c++0x: error returning a lambda function

2010-01-13 Thread vimal78 at gmail dot com


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


-- 


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



[Bug c++/42738] New: nested lambda function: Segmentation fault

2010-01-13 Thread vimal78 at gmail dot com
vi...@linux-718q:~/Study/09C++/c++0x/lambda> g++ -std=c++0x example.cpp
example.cpp: In lambda function:
example.cpp:10:12: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


-- 
   Summary: nested lambda function: Segmentation fault
   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: compiled by GNU C version 4.5.0 20091231
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



[Bug c++/42738] nested lambda function: Segmentation fault

2010-01-13 Thread vimal78 at gmail dot com


--- Comment #1 from vimal78 at gmail dot com  2010-01-13 23:34 ---
Created an attachment (id=19589)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19589&action=view)
example in the draft standard n3000

This is an example in the draft standard n3000.
section 5.1.2 
point 16


-- 


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



[Bug c++/42738] nested lambda function: Segmentation fault

2010-01-13 Thread vimal78 at gmail dot com


--- Comment #2 from vimal78 at gmail dot com  2010-01-13 23:35 ---
Created an attachment (id=19590)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19590&action=view)
generated file


-- 


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



[Bug c++/42738] nested lambda function: Segmentation fault

2010-01-13 Thread vimal78 at gmail dot com


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


-- 


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



[Bug c++/42738] nested lambda function: Segmentation fault

2010-01-13 Thread vimal78 at gmail dot com


-- 

vimal78 at gmail dot com changed:

   What|Removed |Added

   Severity|normal  |major


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



[Bug c++/42741] New: core dump in recursive lambda function

2010-01-13 Thread vimal78 at gmail dot com
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:
vi...@linux-718q:~/Study/09C++/c++0x/lambda> g++ -g -std=c++0x sum.cpp
sum.cpp: In lambda function:
sum.cpp:13:36: error: ‘((*)this)->::sum’
cannot be used as a function



Then i changed the recursive lambda as follows:

std::function 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:

vi...@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< >::_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



[Bug c++/42741] c++0x: core dump in recursive lambda function

2010-01-13 Thread vimal78 at gmail dot com


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



[Bug c++/42741] c++0x: core dump in recursive lambda function

2010-01-13 Thread vimal78 at gmail dot com


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



[Bug c++/42741] c++0x: core dump in recursive lambda function

2010-01-13 Thread vimal78 at gmail dot com


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



[Bug c++/42741] c++0x: core dump in recursive lambda function

2010-01-13 Thread vimal78 at gmail dot com


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



[Bug c++/42741] [c++0x] core dump in recursive lambda function

2010-01-14 Thread vimal78 at gmail dot com


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