public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda
@ 2012-06-30 15:23 vincenzo.innocente at cern dot ch
2012-06-30 15:33 ` [Bug c++/53821] " vincenzo.innocente at cern dot ch
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2012-06-30 15:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
Bug #: 53821
Summary: [4.7.2,4.8 regression][c++11] multiple definitions of
lambda
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vincenzo.innocente@cern.ch
this is a regression as not happening in 4.6.2 and 4.7.1
I personally think that the template methods SHOULD be declared inline if
included in multiple sources…
anyhow since it was discussed at length in PR53780 and PR53768
and got attention from developers I promised to reduce and post
cat inlT.cc
#include <algorithm>
template<typename T> struct Foo {
virtual int bar(int,int);
int k;
};
// int ebar(int,int) __attribute__ ((visibility ("default")));
template<typename T>
int Foo<T>::bar(int i, int j) {
auto ebar = [](int a, int b) { return a+b;};
static int a=i;
if (i>0) k = ebar(i,j);
if (j>0) k = ebar(j,i);
if (i>0) k = ebar(j,i);
if (k>0) k = ebar(i,j);
return (a==i) ? i : j;
}
struct A1 {
Foo<float> * foo;
};
int __attribute__ ((visibility ("default"))) hello1 (int i, int j) { A1 a;
return a.foo->bar(i,j);}
[vocms123] ~/public/ctest/bugs48 $ cat inlT2.cc
#include <algorithm>
template<typename T> struct Foo {
virtual int bar(int,int);
int k;
};
// int ebar(int,int) __attribute__ ((visibility ("default")));
template<typename T>
int Foo<T>::bar(int i, int j) {
auto ebar = [](int a, int b) { return a+b;};
static int a=i;
if (i>0) k = ebar(i,j);
if (j>0) k = ebar(j,i);
if (i>0) k = ebar(j,i);
if (k>0) k = ebar(i,j);
return (a==i) ? i : j;
}
struct A2 {
Foo<float> * foo;
};
int __attribute__ ((visibility ("default"))) hello2 (int i, int j) { A2 a;
return a.foo->bar(i,j);}
[vocms123] ~/public/ctest/bugs48 $ cat buildInlT
c++ -std=gnu++11 -O2 -fvisibility-inlines-hidden -fvisibility=hidden -flto -c
inlT.cc -fPIC
c++ -std=gnu++11 -O2 -fvisibility-inlines-hidden -fvisibility=hidden -flto -c
inlT2.cc -fPIC
c++ -std=gnu++11 -O2 -fvisibility-inlines-hidden -fvisibility=hidden -flto
-shared inlT.o inlT2.o -fPIC -o inlT.so
source buildInlT
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: inlT2.o: multiple
definition of 'Foo<float>::bar(int, int)::{lambda(int, int)#1}::_FUN(int, int)'
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: inlT.o: previous definition
here
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: inlT2.o: multiple
definition of 'Foo<float>::bar(int, int)::{lambda(int, int)#1}::operator int
(*)(int, int)() const'
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: inlT.o: previous definition
here
collect2: error: ld returned 1 exit status
also with simpler
cat buildInlT0
c++ -std=gnu++11 -O2 -c inlT.cc -fPIC
c++ -std=gnu++11 -O2 -c inlT2.cc -fPIC
c++ -std=gnu++11 -O2 -shared inlT.o inlT2.o -fPIC -o inlT.so
source buildInlT0
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: inlT2.o: multiple
definition of 'Foo<float>::bar(int, int)::{lambda(int, int)#1}::_FUN(int, int)'
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: inlT.o: previous definition
here
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: inlT2.o: multiple
definition of 'Foo<float>::bar(int, int)::{lambda(int, int)#1}::operator int
(*)(int, int)() const'
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: inlT.o: previous definition
here
c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/afs/cern.ch/user/i/innocent/w3/gcc47slc5/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.7/configure --enable-languages=c,c++,fortran
--disable-multilib --enable-gold=yes --disable-nls --enable-lto
--with-mpc=/afs/cern.ch/cms/slc5_amd64_gcc470/external/gcc/4.7.0
--with-gmp=/afs/cern.ch/cms/slc5_amd64_gcc470/external/gcc/4.7.0
--with-mpfr=/afs/cern.ch/cms/slc5_amd64_gcc470/external/gcc/4.7.0
--prefix=/afs/cern.ch/user/i/innocent/w3/gcc47slc5
--with-build-time-tools=/build/ge/new-binutils/a/slc5_amd64_gcc470/external/gcc/4.7.0-cms/bin
Thread model: posix
gcc version 4.7.2 20120629 (prerelease) [gcc-4_7-branch revision 189081] (GCC)
[vocms123] ~/public/ctest/bugs48 $ ld -v
GNU gold (GNU Binutils 2.22.52.20120515) 1.11
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7.2,4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
@ 2012-06-30 15:33 ` vincenzo.innocente at cern dot ch
2012-06-30 19:22 ` hjl.tools at gmail dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2012-06-30 15:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
--- Comment #1 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2012-06-30 15:33:15 UTC ---
to clarify:
in compiles and links correctly provided that
template<typename T>
inline
int Foo<T>::bar(int i, int j)
or if instead of the lambda "bar" invokes the external "ebar"
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7.2,4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
2012-06-30 15:33 ` [Bug c++/53821] " vincenzo.innocente at cern dot ch
@ 2012-06-30 19:22 ` hjl.tools at gmail dot com
2012-07-02 8:53 ` [Bug c++/53821] [4.7/4.8 " rguenth at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2012-06-30 19:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-06-30
CC| |jason at redhat dot com
Target Milestone|--- |4.7.2
Ever Confirmed|0 |1
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> 2012-06-30 19:22:16 UTC ---
It is caused by revision 188117:
http://gcc.gnu.org/ml/gcc-cvs/2012-06/msg00027.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
2012-06-30 15:33 ` [Bug c++/53821] " vincenzo.innocente at cern dot ch
2012-06-30 19:22 ` hjl.tools at gmail dot com
@ 2012-07-02 8:53 ` rguenth at gcc dot gnu.org
2012-07-02 10:07 ` redi at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-02 8:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
Known to work| |4.7.1
Summary|[4.7.2,4.8 |[4.7/4.8 regression][c++11]
|regression][c++11] multiple |multiple definitions of
|definitions of lambda |lambda
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (2 preceding siblings ...)
2012-07-02 8:53 ` [Bug c++/53821] [4.7/4.8 " rguenth at gcc dot gnu.org
@ 2012-07-02 10:07 ` redi at gcc dot gnu.org
2012-07-02 19:15 ` jason at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-02 10:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-02 10:07:17 UTC ---
This is PR 53675
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (3 preceding siblings ...)
2012-07-02 10:07 ` redi at gcc dot gnu.org
@ 2012-07-02 19:15 ` jason at gcc dot gnu.org
2012-07-02 19:15 ` jason at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-02 19:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-02 19:14:40 UTC ---
Author: jason
Date: Mon Jul 2 19:14:34 2012
New Revision: 189175
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189175
Log:
PR c++/53821
* semantics.c (maybe_add_lambda_conv_op): Don't set
DECL_INTERFACE_KNOWN.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template6.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/semantics.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (4 preceding siblings ...)
2012-07-02 19:15 ` jason at gcc dot gnu.org
@ 2012-07-02 19:15 ` jason at gcc dot gnu.org
2012-07-02 19:26 ` jason at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-02 19:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-02 19:14:40 UTC ---
Author: jason
Date: Mon Jul 2 19:14:34 2012
New Revision: 189175
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189175
Log:
PR c++/53821
* semantics.c (maybe_add_lambda_conv_op): Don't set
DECL_INTERFACE_KNOWN.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template6.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/semantics.c
trunk/gcc/testsuite/ChangeLog
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-02 19:15:03 UTC ---
Author: jason
Date: Mon Jul 2 19:14:58 2012
New Revision: 189176
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189176
Log:
PR c++/53821
* semantics.c (maybe_add_lambda_conv_op): Don't set
DECL_INTERFACE_KNOWN.
Added:
branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template6.C
Modified:
branches/gcc-4_7-branch/gcc/cp/ChangeLog
branches/gcc-4_7-branch/gcc/cp/semantics.c
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (5 preceding siblings ...)
2012-07-02 19:15 ` jason at gcc dot gnu.org
@ 2012-07-02 19:26 ` jason at gcc dot gnu.org
2012-07-03 20:40 ` vincenzo.innocente at cern dot ch
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-02 19:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution| |FIXED
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-02 19:25:28 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (6 preceding siblings ...)
2012-07-02 19:26 ` jason at gcc dot gnu.org
@ 2012-07-03 20:40 ` vincenzo.innocente at cern dot ch
2012-07-03 20:56 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2012-07-03 20:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
--- Comment #7 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2012-07-03 20:39:50 UTC ---
I'm still wandering, more in general, if there is a semantic difference between
template<typename T>
int Foo<T>::bar(int i, int j) {
…
}
and
template<typename T>
inline
int Foo<T>::bar(int i, int j) {
…
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (7 preceding siblings ...)
2012-07-03 20:40 ` vincenzo.innocente at cern dot ch
@ 2012-07-03 20:56 ` redi at gcc dot gnu.org
2012-07-03 21:28 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-03 20:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |redi at gcc dot gnu.org
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-03 20:55:25 UTC ---
*** Bug 53675 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (8 preceding siblings ...)
2012-07-03 20:56 ` redi at gcc dot gnu.org
@ 2012-07-03 21:28 ` jason at gcc dot gnu.org
2012-12-06 14:38 ` jason at gcc dot gnu.org
2012-12-06 14:40 ` jason at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-03 21:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|jason at redhat dot com |
--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-03 21:28:02 UTC ---
The only difference is the hint to the compiler that you want the function to
be inlined.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (9 preceding siblings ...)
2012-07-03 21:28 ` jason at gcc dot gnu.org
@ 2012-12-06 14:38 ` jason at gcc dot gnu.org
2012-12-06 14:40 ` jason at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-06 14:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2012-12-06 14:37:25 UTC ---
Author: jason
Date: Thu Dec 6 14:37:13 2012
New Revision: 194251
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194251
Log:
PR c++/55015
PR c++/53821
* semantics.c (maybe_add_lambda_conv_op): Revert earlier change.
* decl.c (start_preparsed_function): Make local class methods comdat
in templates, too.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv6.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/cp/semantics.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/53821] [4.7/4.8 regression][c++11] multiple definitions of lambda
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
` (10 preceding siblings ...)
2012-12-06 14:38 ` jason at gcc dot gnu.org
@ 2012-12-06 14:40 ` jason at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-06 14:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53821
--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2012-12-06 14:39:58 UTC ---
Author: jason
Date: Thu Dec 6 14:39:52 2012
New Revision: 194253
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194253
Log:
PR c++/55015
PR c++/53821
* semantics.c (maybe_add_lambda_conv_op): Revert earlier change.
* decl.c (start_preparsed_function): Make local class methods comdat
in templates, too.
Added:
branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv6.C
Modified:
branches/gcc-4_7-branch/gcc/cp/ChangeLog
branches/gcc-4_7-branch/gcc/cp/decl.c
branches/gcc-4_7-branch/gcc/cp/semantics.c
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2012-12-06 14:40 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-30 15:23 [Bug c++/53821] New: [4.7.2,4.8 regression][c++11] multiple definitions of lambda vincenzo.innocente at cern dot ch
2012-06-30 15:33 ` [Bug c++/53821] " vincenzo.innocente at cern dot ch
2012-06-30 19:22 ` hjl.tools at gmail dot com
2012-07-02 8:53 ` [Bug c++/53821] [4.7/4.8 " rguenth at gcc dot gnu.org
2012-07-02 10:07 ` redi at gcc dot gnu.org
2012-07-02 19:15 ` jason at gcc dot gnu.org
2012-07-02 19:15 ` jason at gcc dot gnu.org
2012-07-02 19:26 ` jason at gcc dot gnu.org
2012-07-03 20:40 ` vincenzo.innocente at cern dot ch
2012-07-03 20:56 ` redi at gcc dot gnu.org
2012-07-03 21:28 ` jason at gcc dot gnu.org
2012-12-06 14:38 ` jason at gcc dot gnu.org
2012-12-06 14:40 ` 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).