lundi 1 février 2016

Undefined reference when using lambda

The following code produces undefined reference error on c++ (Debian 4.7.2-5) 4.7.2:

#include <signal.h>

class Lol {
public:
    void foo() {
        struct sigaction sa;
        sa.sa_flags = 0;
        sigemptyset(&sa.sa_mask);
        sa.sa_handler = [](int) {
        };
        sigaction(SIGTERM, &sa, 0);
    }
};

int main() {
    Lol l;
    l.foo();
}

lev@debi7:~$ c++ -std=c++11 -o lol lol.cpp

/tmp/ccWFXAT9.o: In function `Lol::foo()::{lambda(int)#1}::operator void (*)(int)() const': lol.cpp (.text._ZZN3Lol3fooEvENKUliE_cvPFviEEv[_ZZN3Lol3fooEvENKUliE_cvPFviEEv]+0 9): undefined reference to `Lol::foo()::{lambda(int)#1}::_FUN(int)' collect2: error: ld returned 1 exit status
lev@debi7:~$ c++ --version
c++ (Debian 4.7.2-5) 4.7.2

However it compiles/links perfectly fine on g++-4.7.real (Ubuntu/Linaro 4.7.4-3ubuntu3) 4.7.4.

What is going on here?

Aucun commentaire:

Enregistrer un commentaire