ここで何が間違っているのかわかりません。この非常に短いプログラム:
#include <iostream>
#include <string>
#include <atomic>
#include <thread>
using namespace std;
int
main(int argc, char ** argv)
{
thread foo( []() {
cout << "Hello World" << endl;
return 0;
} );
foo.join();
return 0;
}
でコンパイルすると完全に機能しgcc (4.7.2)
ます:
$ g++ -ggdb -std=c++11 -pthread -o clang_thread_test clang_thread_test.cpp
$ ./clang_thread_test
Hello World
ただし、コンパイルするclang (3.2; x86_64-pc-linux-gnu; thread model: posix)
と実行に失敗します。
$ clang++ -ggdb -std=c++11 -pthread -o clang_thread_test clang_thread_test.cpp
$ ./clang_thread_test
pure virtual method called
terminate called without an active exception
Aborted
これには既知の理由がありますか?私が見つけた唯一のものは、行方不明-pthread switch
または未使用に関連していましたlibc++
。私の知る限り、後者はアップルシステムにのみ関連しています。