public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57437] New: C++11: mutable lambdas; gcc 4.7-4.8
@ 2013-05-27 21:29 alxchk at alxchk dot me
  2013-05-28  6:41 ` [Bug c++/57437] " daniel.kruegler at googlemail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: alxchk at alxchk dot me @ 2013-05-27 21:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57437
           Summary: C++11: mutable lambdas; gcc 4.7-4.8
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alxchk at alxchk dot me

> cat test.cpp
#include <vector>
#include <iostream>

int main(int argc, char *argv[])
{
  auto x = std::vector<int>({1, 2, 3});

  auto y = [x] () 
    mutable {
    for (auto &i: x)
      i ++;
    return x;
  };

  for (const auto &i: y())
    std::cout << i << std::endl;

  for (const auto &i: y())
    std::cout << i << std::endl;

  return 0;
}

> x86_64-pc-linux-gnu-g++-4.6.3 -o test test.cpp -std=gnu++0x
> ./test
2
3
4
3
4
5
> LC_ALL=C x86_64-pc-linux-gnu-g++-4.6.3 -v 
Using built-in specs.
COLLECT_GCC=x86_64-pc-linux-gnu-g++-4.6.3
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/portage/sys-devel/gcc-4.6.3/work/gcc-4.6.3/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check
--with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls
--without-included-gettext --with-system-zlib --enable-obsolete
--disable-werror --enable-secureplt --enable-multilib --enable-libmudflap
--disable-libssp --enable-esp --enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/python
--enable-checking=release --disable-libgcj --enable-libstdcxx-time
--enable-languages=c,c++,objc,fortran --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.6.3
p1.11, pie-0.5.2'
Thread model: posix
gcc version 4.6.3 (Gentoo Hardened 4.6.3 p1.11, pie-0.5.2)


> x86_64-pc-linux-gnu-g++-4.7.2 -o test2 test.cpp -std=gnu++0x 
> ./test2
2
3
4

> LC_ALL=C x86_64-pc-linux-gnu-g++-4.7.2 -v     
Using built-in specs.
COLLECT_GCC=x86_64-pc-linux-gnu-g++-4.7.2
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.2/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/portage/sys-devel/gcc-4.7.2-r1/work/gcc-4.7.2/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.2
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check
--with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls
--without-included-gettext --with-system-zlib --enable-obsolete
--disable-werror --enable-secureplt --enable-multilib
--with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-esp
--enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/python
--enable-checking=release --disable-libgcj --enable-libstdcxx-time
--enable-languages=c,c++,objc,fortran --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened
4.7.2-r1 p1.5, pie-0.5.5'
Thread model: posix
gcc version 4.7.2 (Gentoo Hardened 4.7.2-r1 p1.5, pie-0.5.5)

> x86_64-pc-linux-gnu-g++-4.8.0 -o test test.cpp -std=gnu++11
> ./test
2
3
4

> LC_ALL=C x86_64-pc-linux-gnu-g++-4.8.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-pc-linux-gnu-g++-4.8.0
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/portage/sys-devel/gcc-4.8.0/work/gcc-4.8.0/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --disable-isl-version-check
--with-cloog --enable-lto --enable-nls --without-included-gettext
--with-system-zlib --enable-obsolete --disable-werror --enable-secureplt
--enable-multilib --with-multilib-list=m32,m64 --disable-libmudflap
--disable-libssp --enable-esp --enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/python
--enable-checking=release --disable-libgcj --enable-libstdcxx-time
--disable-libquadmath --enable-languages=c,c++ --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--enable-targets=all --with-bugurl=http://bugs.gentoo.org/
--with-pkgversion='Gentoo Hardened 4.8.0 p1.2, pie-0.5.5'
Thread model: posix
gcc version 4.8.0 (Gentoo Hardened 4.8.0 p1.2, pie-0.5.5)


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

* [Bug c++/57437] C++11: mutable lambdas; gcc 4.7-4.8
  2013-05-27 21:29 [Bug c++/57437] New: C++11: mutable lambdas; gcc 4.7-4.8 alxchk at alxchk dot me
@ 2013-05-28  6:41 ` daniel.kruegler at googlemail dot com
  2013-05-28 10:00 ` [Bug c++/57437] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-05-28  6:41 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
I can confirm the problem for my mingw-64-bit system using gcc 4.9.0 20130519
(experimental).

A variation of the program:

//-------------------------------------------------
#include <vector>
#include <iostream>

int main()
{
  std::vector<int> x{1, 2, 3};

  auto y = [x] () mutable {
    for (auto &i: x)
      i++;
    return x;
  };

  for (const auto &i : y()) {
    std::cout << i << std::endl;
  }

  std::cout << "(1)" << std::endl;

  for (const auto &i : y()) {
    std::cout << i << std::endl;
  }

  std::cout << "(2)" << std::endl;
}
//-------------------------------------------------

produces the output:

2
3
4
(1)
(2)

I *think* the following is going on here: The actual closure member x is
(incorrectly) considered as a local variable during RVO analysis, therefore the
first invocation invokes the move constructor on that member with the effect of
leaving an empty vector x within the closure.

The behavior looks incorrect to me: Neither 12.8 p31 b1 nor p32 can be applied
here, because x is neither a variable with automatic storage duration nor a
function parameter. It is correct the 5.1.2 p10 says 

"The identifier in a simple-capture is looked up using the usual rules for
unqualified name lookup (3.4.1); each such lookup shall find a variable with
automatic storage duration declared in the reaching scope of the local lambda
expression."

but this is an automatic variable *not* within the closure's function call
operator. And 5.1.2 p15

"For each entity captured by copy, an unnamed nonstatic data member is declared
in the closure type."

is clear that x is considered a data member within the closure and RVO shall
not be applied to it.
>From gcc-bugs-return-423244-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue May 28 07:00:06 2013
Return-Path: <gcc-bugs-return-423244-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22632 invoked by alias); 28 May 2013 07:00:05 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 21578 invoked by uid 48); 28 May 2013 06:59:49 -0000
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/57435] [4.8/4.9 Regression] Ice on invalid: check_for_ambiguous
Date: Tue, 28 May 2013 07:00:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: ice-on-invalid-code
X-Bugzilla-Severity: minor
X-Bugzilla-Who: burnus at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.1
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: keywords cc target_milestone
Message-ID: <bug-57435-4-Esw6HeZoCu@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57435-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57435-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-05/txt/msg01917.txt.bz2
Content-length: 773

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW435

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
                 CC|                            |burnus at gcc dot gnu.org
   Target Milestone|---                         |4.8.1

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #3)
> Likely due to revision 195065:

Looks like (see PR 47203 / http://gcc.gnu.org/r195065).

(In reply to Dominique d'Humieres from comment #4)
> The following patch restores the 4.7 behavior:

The patch looks good to me.


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

* [Bug c++/57437] [4.7/4.8/4.9 Regression] C++11: mutable lambdas; gcc 4.7-4.8
  2013-05-27 21:29 [Bug c++/57437] New: C++11: mutable lambdas; gcc 4.7-4.8 alxchk at alxchk dot me
  2013-05-28  6:41 ` [Bug c++/57437] " daniel.kruegler at googlemail dot com
@ 2013-05-28 10:00 ` redi at gcc dot gnu.org
  2013-07-09  6:54 ` [Bug c++/57437] [4.7/4.8/4.9 Regression] C++11: mutable lambdas jason at gcc dot gnu.org
  2013-07-09 18:52 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-28 10:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-05-28
      Known to work|                            |4.6.3
            Summary|C++11: mutable lambdas; gcc |[4.7/4.8/4.9 Regression]
                   |4.7-4.8                     |C++11: mutable lambdas; gcc
                   |                            |4.7-4.8
     Ever confirmed|0                           |1


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

* [Bug c++/57437] [4.7/4.8/4.9 Regression] C++11: mutable lambdas
  2013-05-27 21:29 [Bug c++/57437] New: C++11: mutable lambdas; gcc 4.7-4.8 alxchk at alxchk dot me
  2013-05-28  6:41 ` [Bug c++/57437] " daniel.kruegler at googlemail dot com
  2013-05-28 10:00 ` [Bug c++/57437] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
@ 2013-07-09  6:54 ` jason at gcc dot gnu.org
  2013-07-09 18:52 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2013-07-09  6:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

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


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

* [Bug c++/57437] [4.7/4.8/4.9 Regression] C++11: mutable lambdas
  2013-05-27 21:29 [Bug c++/57437] New: C++11: mutable lambdas; gcc 4.7-4.8 alxchk at alxchk dot me
                   ` (2 preceding siblings ...)
  2013-07-09  6:54 ` [Bug c++/57437] [4.7/4.8/4.9 Regression] C++11: mutable lambdas jason at gcc dot gnu.org
@ 2013-07-09 18:52 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2013-07-09 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 4.7.4/4.8.2/4.9.


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

end of thread, other threads:[~2013-07-09 18:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-27 21:29 [Bug c++/57437] New: C++11: mutable lambdas; gcc 4.7-4.8 alxchk at alxchk dot me
2013-05-28  6:41 ` [Bug c++/57437] " daniel.kruegler at googlemail dot com
2013-05-28 10:00 ` [Bug c++/57437] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
2013-07-09  6:54 ` [Bug c++/57437] [4.7/4.8/4.9 Regression] C++11: mutable lambdas jason at gcc dot gnu.org
2013-07-09 18:52 ` 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).