public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56901] New: [4.9 regression] lambda with implicit capture by reference
@ 2013-04-10  8:29 zeratul976 at hotmail dot com
  2013-04-10  8:30 ` [Bug c++/56901] " zeratul976 at hotmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zeratul976 at hotmail dot com @ 2013-04-10  8:29 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56901
           Summary: [4.9 regression] lambda with implicit capture by
                    reference
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zeratul976@hotmail.com


The following code compiles with gcc 4.8 and clang, but not with gcc 4.9:


template <typename>
void foo_impl()
{
    int data;
    auto L = [&](){ return data; };
    [&](){ L(); }();
}

void foo()
{
    foo_impl<int>();
}


The error is:


test.cpp: In instantiation of 'foo_impl() [with <template-parameter-1-1> =
int]::__lambda1':
test.cpp:6:12:   required from 'struct foo_impl() [with
<template-parameter-1-1> = int]::__lambda1'
test.cpp:6:19:   required from 'void foo_impl() [with <template-parameter-1-1>
= int]'
test.cpp:11:19:   required from here
test.cpp:5:14: error: uninitialized const member 'foo_impl() [with
<template-parameter-1-1> = int]::__lambda0::__data'
     auto L = [&](){ return data; };
              ^


The error goes away if:
  - foo_impl is made a nontemplate
  - the call to the second lambda is inlined
  - either lambda is made to capture by value instead of reference


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

* [Bug c++/56901] [4.9 regression] lambda with implicit capture by reference
  2013-04-10  8:29 [Bug c++/56901] New: [4.9 regression] lambda with implicit capture by reference zeratul976 at hotmail dot com
@ 2013-04-10  8:30 ` zeratul976 at hotmail dot com
  2013-04-10  8:50 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: zeratul976 at hotmail dot com @ 2013-04-10  8:30 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Nathan Ridge <zeratul976 at hotmail dot com> 2013-04-10 08:30:23 UTC ---
Tested with r197663.


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

* [Bug c++/56901] [4.9 regression] lambda with implicit capture by reference
  2013-04-10  8:29 [Bug c++/56901] New: [4.9 regression] lambda with implicit capture by reference zeratul976 at hotmail dot com
  2013-04-10  8:30 ` [Bug c++/56901] " zeratul976 at hotmail dot com
@ 2013-04-10  8:50 ` paolo.carlini at oracle dot com
  2013-04-10  9:30 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-10  8:50 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-04-10
             Blocks|                            |54367
     Ever Confirmed|0                           |1


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

* [Bug c++/56901] [4.9 regression] lambda with implicit capture by reference
  2013-04-10  8:29 [Bug c++/56901] New: [4.9 regression] lambda with implicit capture by reference zeratul976 at hotmail dot com
  2013-04-10  8:30 ` [Bug c++/56901] " zeratul976 at hotmail dot com
  2013-04-10  8:50 ` paolo.carlini at oracle dot com
@ 2013-04-10  9:30 ` rguenth at gcc dot gnu.org
  2013-04-11 16:51 ` jason at gcc dot gnu.org
  2013-04-16 21:43 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-10  9:30 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.9.0


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

* [Bug c++/56901] [4.9 regression] lambda with implicit capture by reference
  2013-04-10  8:29 [Bug c++/56901] New: [4.9 regression] lambda with implicit capture by reference zeratul976 at hotmail dot com
                   ` (2 preceding siblings ...)
  2013-04-10  9:30 ` rguenth at gcc dot gnu.org
@ 2013-04-11 16:51 ` jason at gcc dot gnu.org
  2013-04-16 21:43 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2013-04-11 16:51 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2013-04-11 16:51:12 UTC ---
Fixed.


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

* [Bug c++/56901] [4.9 regression] lambda with implicit capture by reference
  2013-04-10  8:29 [Bug c++/56901] New: [4.9 regression] lambda with implicit capture by reference zeratul976 at hotmail dot com
                   ` (3 preceding siblings ...)
  2013-04-11 16:51 ` jason at gcc dot gnu.org
@ 2013-04-16 21:43 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2013-04-16 21:43 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rmansfield at qnx dot com

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2013-04-16 21:43:38 UTC ---
*** Bug 56857 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2013-04-16 21:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10  8:29 [Bug c++/56901] New: [4.9 regression] lambda with implicit capture by reference zeratul976 at hotmail dot com
2013-04-10  8:30 ` [Bug c++/56901] " zeratul976 at hotmail dot com
2013-04-10  8:50 ` paolo.carlini at oracle dot com
2013-04-10  9:30 ` rguenth at gcc dot gnu.org
2013-04-11 16:51 ` jason at gcc dot gnu.org
2013-04-16 21:43 ` jason at gcc dot gnu.org

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