public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error
@ 2015-04-22 10:03 darklin20 at gmail dot com
  2015-04-22 10:52 ` [Bug c++/65843] [5/6 Regression] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: darklin20 at gmail dot com @ 2015-04-22 10:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65843

            Bug ID: 65843
           Summary: multiple use of const variable in lamba in template
                    function causes compile error
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: darklin20 at gmail dot com

The source code in next report is completely valid source code but GCC
5.0.0 rejects to compile it.
Older version of GCC can compile this.
I tested this in Ubuntu but I've got the same report in fedora from other user.

If I change the type of varaible 'a' to int from const int, or make the test
function non-template, it can be compiled.
-------------------------------------------------------------------------------

the exact version of GCC
5.0.0 20150329 (experimental) [trunk revision 221764] (Ubuntu
5-20150329-1ubuntu11~14.04)

the system type
x86_64-linux-gnu

the options given when GCC was configured/built
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5-20150329-1ubuntu11~14.04'
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++
--prefix=/usr --program-suffix=-5 --enable-shared
--enable-linker-build-id --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/5 --libdir=/usr/lib
--enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=c++98 --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=yes --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu

the complete command line that triggers the bug
g++-5 -std=c++11 test.cpp

the compiler output (error messages, warnings, etc.)
test.cpp: In instantiation of 'test(T)::<lambda()> [with T = int]':
test.cpp:5:7:   required from 'struct test(T) [with T = int]::<lambda()>'
test.cpp:5:28:   required from 'void test(T) [with T = int]'
test.cpp:9:11:   required from here
test.cpp:5:27: error: redeclaration of 'const int& a'
     [&] () { return a, a; }();
                           ^
test.cpp:5:27: note: 'const int& a' previously declared here
test.cpp: In instantiation of 'void test(T) [with T = int]':
test.cpp:9:11:   required from here
test.cpp:5:5: sorry, unimplemented: non-trivial designated
initializers not supported
     [&] () { return a, a; }();

the preprocessed file (*.i*) that triggers the bug
# 1 "test.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "test.cpp"
template<class T>
void test(T b)
{
    const int a = b;
    [&] () { return a, a; }();
}

int main() {
    test(1);
 return 0;
}


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

* [Bug c++/65843] [5/6 Regression] multiple use of const variable in lamba in template function causes compile error
  2015-04-22 10:03 [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error darklin20 at gmail dot com
@ 2015-04-22 10:52 ` redi at gcc dot gnu.org
  2015-04-25 13:46 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-22 10:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65843

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-04-22
      Known to work|                            |4.9.2
            Summary|multiple use of const       |[5/6 Regression] multiple
                   |variable in lamba in        |use of const variable in
                   |template function causes    |lamba in template function
                   |compile error               |causes compile error
     Ever confirmed|0                           |1
           Severity|major                       |normal


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

* [Bug c++/65843] [5/6 Regression] multiple use of const variable in lamba in template function causes compile error
  2015-04-22 10:03 [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error darklin20 at gmail dot com
  2015-04-22 10:52 ` [Bug c++/65843] [5/6 Regression] " redi at gcc dot gnu.org
@ 2015-04-25 13:46 ` redi at gcc dot gnu.org
  2015-06-03  5:07 ` sebastien.alaiwan at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-25 13:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65843

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |myoga.murase at gmail dot com

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 65885 has been marked as a duplicate of this bug. ***


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

* [Bug c++/65843] [5/6 Regression] multiple use of const variable in lamba in template function causes compile error
  2015-04-22 10:03 [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error darklin20 at gmail dot com
  2015-04-22 10:52 ` [Bug c++/65843] [5/6 Regression] " redi at gcc dot gnu.org
  2015-04-25 13:46 ` redi at gcc dot gnu.org
@ 2015-06-03  5:07 ` sebastien.alaiwan at gmail dot com
  2015-06-19 14:34 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: sebastien.alaiwan at gmail dot com @ 2015-06-03  5:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65843

Sebastien Alaiwan <sebastien.alaiwan at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sebastien.alaiwan at gmail dot com

--- Comment #2 from Sebastien Alaiwan <sebastien.alaiwan at gmail dot com> ---
*** Bug 66374 has been marked as a duplicate of this bug. ***


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

* [Bug c++/65843] [5/6 Regression] multiple use of const variable in lamba in template function causes compile error
  2015-04-22 10:03 [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error darklin20 at gmail dot com
                   ` (2 preceding siblings ...)
  2015-06-03  5:07 ` sebastien.alaiwan at gmail dot com
@ 2015-06-19 14:34 ` jason at gcc dot gnu.org
  2015-06-19 18:16 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-19 14:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65843

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] 8+ messages in thread

* [Bug c++/65843] [5/6 Regression] multiple use of const variable in lamba in template function causes compile error
  2015-04-22 10:03 [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error darklin20 at gmail dot com
                   ` (3 preceding siblings ...)
  2015-06-19 14:34 ` jason at gcc dot gnu.org
@ 2015-06-19 18:16 ` jason at gcc dot gnu.org
  2015-06-19 18:25 ` jason at gcc dot gnu.org
  2015-06-22 17:37 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-19 18:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65843

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Jun 19 18:15:24 2015
New Revision: 224676

URL: https://gcc.gnu.org/viewcvs?rev=224676&root=gcc&view=rev
Log:
        PR c++/65843
        * pt.c (tsubst_copy_and_build): Register a capture proxy in
        local_specializations.

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


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

* [Bug c++/65843] [5/6 Regression] multiple use of const variable in lamba in template function causes compile error
  2015-04-22 10:03 [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error darklin20 at gmail dot com
                   ` (4 preceding siblings ...)
  2015-06-19 18:16 ` jason at gcc dot gnu.org
@ 2015-06-19 18:25 ` jason at gcc dot gnu.org
  2015-06-22 17:37 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-19 18:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65843

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Jun 19 18:24:18 2015
New Revision: 224681

URL: https://gcc.gnu.org/viewcvs?rev=224681&root=gcc&view=rev
Log:
        PR c++/65843
        * pt.c (tsubst_copy_and_build): Register a capture proxy in
        local_specializations.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-rep1.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/pt.c


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

* [Bug c++/65843] [5/6 Regression] multiple use of const variable in lamba in template function causes compile error
  2015-04-22 10:03 [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error darklin20 at gmail dot com
                   ` (5 preceding siblings ...)
  2015-06-19 18:25 ` jason at gcc dot gnu.org
@ 2015-06-22 17:37 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-22 17:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65843

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

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 5.2.


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

end of thread, other threads:[~2015-06-22 17:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-22 10:03 [Bug c++/65843] New: multiple use of const variable in lamba in template function causes compile error darklin20 at gmail dot com
2015-04-22 10:52 ` [Bug c++/65843] [5/6 Regression] " redi at gcc dot gnu.org
2015-04-25 13:46 ` redi at gcc dot gnu.org
2015-06-03  5:07 ` sebastien.alaiwan at gmail dot com
2015-06-19 14:34 ` jason at gcc dot gnu.org
2015-06-19 18:16 ` jason at gcc dot gnu.org
2015-06-19 18:25 ` jason at gcc dot gnu.org
2015-06-22 17:37 ` 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).