This code:
#include <iostream>
#include <future>
int main()
{
std::async([]{std::cout << "hello\n";}).get();
}
runs fine and prints hello
with Visual C++ 2013, but throws an exception with gcc producing:
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
and doesn't even build with clang, producing this error message:
/usr/bin/ld: /tmp/source-83f28e.o: undefined reference to symbol 'pthread_setspecific@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I used rexter to run the tests. Can you explain this behavior?
EDIT
With -pthread
compiler option gcc version runs fine and clang version builds now and produces:
hello
exception_ptr not yet implemented