で改善されたリンク時間最適化サポートについて読んだg++-4.9
ので、試してみたいと思います。悲しいことに、実行時に例外が発生しますstd::system_error
。特にe.what() == Enable multithreading to use std::thread: Operation not permitted
.
これで、通常、そのエラーを修正する方法がわかりまし-pthread
た。コンパイラの呼び出しに追加しますが、実際には、このパラメーターが既にあります。
私のサンプルコードは次のとおりです。
#include <thread>
int main()
{
std::thread t([](){}); // do nothing in a thread!
t.join(); // wait for nothing to be done
}
コンパイル済み (X は 7、8、または 9)
g++-4.X -std=c++11 -pthread test.cpp -o thread_test_fine
期待どおりに問題なく動作し、実行時エラーはありません。
でも、
g++-4.X -std=c++11 -pthread -flto test.cpp -o thread_test_runtime_error
例外で失敗しsystem_error
ます。
質問:
この動作は意図されたものですか (修正は何ですか?)、それともバグですか?
(この質問が出る前に: 私のコンパイラはすべて でビルドされています--enable-threads=posix
)