public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49598] New: Ice on lambda with implicit capture by value.
@ 2011-06-30 20:31 3dw4rd at verizon dot net
  2011-06-30 20:44 ` [Bug c++/49598] " 3dw4rd at verizon dot net
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: 3dw4rd at verizon dot net @ 2011-06-30 20:31 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Ice on lambda with implicit capture by value.
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: 3dw4rd@verizon.net


I have a brand new (r175707) 4.7 build on x86_64 GNU/Linux.

I saw an error with lambdas on stackoverflow:
-----------------------------------------------
#include <iostream>

using std::cout;
using std::endl;

int
main()
{
  int i = 10;
  int& ir = i;

  [=] // [i, ir] explicit capture works.
  {
      cout << "value capture" << endl
           << "i: " << i << endl
           << "ir: " << ir << endl
           << "&i: " << &i << endl
           << "&ir: " << &ir << endl
           << endl;
  }();
}
-----------------------------------------------

This is reduced somewhat.

I get:
-----------------------------------------------
[ed@localhost ~]$ ./bin/bin/g++ -std=c++0x -o lamb2 lamb2.cpp
lamb2.cpp: In function ‘int main()’:
lamb2.cpp:10:1: error: non-trivial conversion at assignment
int
int &
D.28407.__ir = ir;

lamb2.cpp:10:1: internal compiler error: verify_gimple failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
-----------------------------------------------


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

* [Bug c++/49598] Ice on lambda with implicit capture by value.
  2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
@ 2011-06-30 20:44 ` 3dw4rd at verizon dot net
  2011-07-02  0:53 ` [Bug c++/49598] [C++0x] " 3dw4rd at verizon dot net
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: 3dw4rd at verizon dot net @ 2011-06-30 20:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Ed Smith-Rowland <3dw4rd at verizon dot net> 2011-06-30 20:43:39 UTC ---
Reduced testcase:
-----------------------------------------
int
main()
{
  int i = 10;
  int& ir = i;

  [=] // [i, ir] explicit capture works.
  {
       i == ir;
  }();
}
-----------------------------------------
With [=, ir] I get a warning:
lamb3.cpp:10:7: warning: explicit by-copy capture of ‘ir’ redundant with
by-copy capture default [enabled by default]
But it compiles.

With [=, i] I get the ICE.


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

* [Bug c++/49598] [C++0x] Ice on lambda with implicit capture by value.
  2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
  2011-06-30 20:44 ` [Bug c++/49598] " 3dw4rd at verizon dot net
@ 2011-07-02  0:53 ` 3dw4rd at verizon dot net
  2011-07-02 11:26 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: 3dw4rd at verizon dot net @ 2011-07-02  0:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Ed Smith-Rowland <3dw4rd at verizon dot net> 2011-07-02 00:52:57 UTC ---
This compiled on gcc-4.5 but the answer is junk.

ed@bad-horse:~$ g++ -std=c++0x -o lamb2 lamb2.cpp
ed@bad-horse:~$ ./lamb2 
value capture
i: 10
ir: 617467132
&i: 0x7fff24cdcce0
&ir: 0x7fff24cdcce4


Compiler version of compile but junk answer:

ed@bad-horse:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.5 --enable-shared --enable-multiarch
--with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/x86_64-linux-gnu
--enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default
--with-plugin-ld=ld.gold --enable-objc-gc --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)


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

* [Bug c++/49598] [C++0x] Ice on lambda with implicit capture by value.
  2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
  2011-06-30 20:44 ` [Bug c++/49598] " 3dw4rd at verizon dot net
  2011-07-02  0:53 ` [Bug c++/49598] [C++0x] " 3dw4rd at verizon dot net
@ 2011-07-02 11:26 ` redi at gcc dot gnu.org
  2011-07-05  5:14 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-07-02 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.07.02 11:25:48
                 CC|                            |jason at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-07-02 11:25:48 UTC ---
The ICE seems to be when initialising the closure type's data member for an
object of reference type implicitly-captured by copy.

Slightly further reduced:

int
main()
{
  int i = 10;
  int& ir = i;

  [=] 
  {
       (void) ir;
  }();
}


(In reply to comment #1)
> With [=, ir] I get a warning:
> lamb3.cpp:10:7: warning: explicit by-copy capture of ‘ir’ redundant with
> by-copy capture default [enabled by default]
> But it compiles.
> 
> With [=, i] I get the ICE.

That's invalid:
"If a lambda-capture includes a capture-default that is =, the lambda-capture
shall not contain this and each identifier it contains shall be preceded by &."


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

* [Bug c++/49598] [C++0x] Ice on lambda with implicit capture by value.
  2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
                   ` (2 preceding siblings ...)
  2011-07-02 11:26 ` redi at gcc dot gnu.org
@ 2011-07-05  5:14 ` jason at gcc dot gnu.org
  2011-07-05 14:48 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-05  5:14 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/49598] [C++0x] Ice on lambda with implicit capture by value.
  2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
                   ` (3 preceding siblings ...)
  2011-07-05  5:14 ` jason at gcc dot gnu.org
@ 2011-07-05 14:48 ` jason at gcc dot gnu.org
  2011-07-05 14:52 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-05 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-05 14:47:26 UTC ---
Author: jason
Date: Tue Jul  5 14:47:21 2011
New Revision: 175857

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175857
Log:
    PR c++/49598
    * semantics.c (finish_id_expression): convert_from_reference.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/49598] [C++0x] Ice on lambda with implicit capture by value.
  2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
                   ` (4 preceding siblings ...)
  2011-07-05 14:48 ` jason at gcc dot gnu.org
@ 2011-07-05 14:52 ` jason at gcc dot gnu.org
  2011-07-05 20:02 ` jason at gcc dot gnu.org
  2011-07-16 17:30 ` iorate_stage at yahoo dot co.jp
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-05 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-05 14:51:59 UTC ---
Author: jason
Date: Tue Jul  5 14:51:56 2011
New Revision: 175863

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175863
Log:
    PR c++/49598
    * semantics.c (finish_id_expression): convert_from_reference.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/semantics.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/49598] [C++0x] Ice on lambda with implicit capture by value.
  2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
                   ` (5 preceding siblings ...)
  2011-07-05 14:52 ` jason at gcc dot gnu.org
@ 2011-07-05 20:02 ` jason at gcc dot gnu.org
  2011-07-16 17:30 ` iorate_stage at yahoo dot co.jp
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-05 20:02 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.2

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-05 20:01:34 UTC ---
Fixed (output as well as crash) for 4.6.2.


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

* [Bug c++/49598] [C++0x] Ice on lambda with implicit capture by value.
  2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
                   ` (6 preceding siblings ...)
  2011-07-05 20:02 ` jason at gcc dot gnu.org
@ 2011-07-16 17:30 ` iorate_stage at yahoo dot co.jp
  7 siblings, 0 replies; 9+ messages in thread
From: iorate_stage at yahoo dot co.jp @ 2011-07-16 17:30 UTC (permalink / raw)
  To: gcc-bugs

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

iorate <iorate_stage at yahoo dot co.jp> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iorate_stage at yahoo dot
                   |                            |co.jp

--- Comment #7 from iorate <iorate_stage at yahoo dot co.jp> 2011-07-16 17:29:41 UTC ---
*** Bug 49763 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2011-07-16 17:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30 20:31 [Bug c++/49598] New: Ice on lambda with implicit capture by value 3dw4rd at verizon dot net
2011-06-30 20:44 ` [Bug c++/49598] " 3dw4rd at verizon dot net
2011-07-02  0:53 ` [Bug c++/49598] [C++0x] " 3dw4rd at verizon dot net
2011-07-02 11:26 ` redi at gcc dot gnu.org
2011-07-05  5:14 ` jason at gcc dot gnu.org
2011-07-05 14:48 ` jason at gcc dot gnu.org
2011-07-05 14:52 ` jason at gcc dot gnu.org
2011-07-05 20:02 ` jason at gcc dot gnu.org
2011-07-16 17:30 ` iorate_stage at yahoo dot co.jp

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