Bug 55720 - [C++11] Linkage errors of static data member initializers with lambdas
Summary: [C++11] Linkage errors of static data member initializers with lambdas
Status: RESOLVED DUPLICATE of bug 55710
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda, link-failure
: 55834 (view as bug list)
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2012-12-17 14:00 UTC by Daniel Krügler
Modified: 2022-03-11 00:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.7.2, 4.8.0
Last reconfirmed: 2013-01-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2012-12-17 14:00:57 UTC
The following program compiled with gcc 4.7.2 using the flags

-Wall -std=c++0x -pedantic

//------------------------
template <class T>
struct X {
  static void (*code) ();
};

template <class T>
void (*X<T>::code) () = []{};  // Line 7

int main () {
  X<int>::code();
}
//------------------------

gives a linkage error:

"|In function `X<int>::code::{lambda()#1}::operator void (*)()() const':|
7|undefined reference to `X<int>::code::{lambda()#1}::_FUN()'|
"

The code should be accepted.
Comment 1 Daniel Krügler 2012-12-17 14:04:46 UTC
This is a split-off of bug 55710.

The error also occurs on gcc 4.8.0 20121209 (experimental).
Comment 2 Paolo Carlini 2013-01-07 17:09:38 UTC
*** Bug 55834 has been marked as a duplicate of this bug. ***
Comment 3 Jason Merrill 2013-02-13 18:15:42 UTC
There's no need to split this out.

*** This bug has been marked as a duplicate of bug 55710 ***