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



             Bug #: 55720

           Summary: [C++11] Linkage errors of static data member

                    initializers with lambdas

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: daniel.krueg...@googlemail.com





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.

Reply via email to