mercredi 22 juillet 2015

Undefined reference to typeinfo for decltype(nullptr)

I tried to compile simple code int main() { throw nullptr; } and got an error:

/tmp/main-ea26ec.o: In function `main':
main.cpp:(.text+0x13): undefined reference to `typeinfo for decltype(nullptr)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The command line is: clang++ -std=gnu++1z -stdlib=libc++ -Ofast -march=native -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-newline-eof main.cpp -o a && ./a. clang++ version is clang version 3.6.0 (tags/RELEASE_360/final 235480) (from coliru).

I look through related questions and there was an issues with virtual functions, but type std::nullptr_t is not class and has no member functions.

What is the source of the error?

I also tried to add auto const & unused = typeid(std::nullptr_t); to make force generation of typeinfo for nullptr (is it wrong?), but it gives nothing.

Aucun commentaire:

Enregistrer un commentaire