This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/55710] New: [C++11] Linkage errors with lambdas
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 15 Dec 2012 17:10:42 +0000
- Subject: [Bug c++/55710] New: [C++11] Linkage errors with lambdas
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710
Bug #: 55710
Summary: [C++11] Linkage errors with lambdas
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
The following program compiled with gcc 4.8.0 20121209 (experimental) and
compiled with flags
-Wall -std=c++11 -pedantic
//----------------
template <class T>
struct X {
static void (*code) ();
};
template <class T>
void (*X<T>::code) () = []{}; // Line 7
struct Y {
void (*code) () = []{} ; // Line 10
void operator()() { code(); }
};
int main () {
X<int>::code();
Y()();
}
//----------------
gives two linkage errors:
"|In function `Y::code::{lambda()#1}::operator void (*)()() const':|
10|undefined reference to `Y::code::{lambda()#1}::_FUN()'|
|In function `X<int>::code::{lambda()#1}::operator void (*)()() const':|
7|undefined reference to `X<int>::code::{lambda()#1}::_FUN()'|
"
for the functions that should be defined for the corresponding uncaptured
lambda expressions.
It should be noted, that
struct Z {
static void (*code) ();
};
void (*Z::code) () = []{};
int main () {
Z::code();
}
doesn't cause a similar linkage error, though.