C++ SIGABRT从未来检索值时
我在使用C++11时遇到问题。当我对C++ SIGABRT从未来检索值时,c++,c++11,C++,C++11,我在使用C++11时遇到问题。当我对std::async返回的future调用wait()或get()时,程序接收从互斥体头抛出的SIGABRT信号。有什么问题吗?如何修复它 我在Linux上使用g++4.6。将以下代码粘贴到ideone.com会导致相同的问题 #include <future> #include <thread> int calculate() { return 1; } int main() { auto result = std
std::async
返回的future调用wait()
或get()
时,程序接收从互斥体
头抛出的SIGABRT信号。有什么问题吗?如何修复它
我在Linux上使用g++4.6。将以下代码粘贴到ideone.com会导致相同的问题
#include <future>
#include <thread>
int calculate() {
return 1;
}
int main() {
auto result = std::async(calculate);
result.wait();// <-- this aborts
int value = result.get();// <-- or this aborts as well if previous line is commented out.
return 0;
}
#包括
#包括
int计算(){
返回1;
}
int main(){
自动结果=标准::异步(计算);
result.wait();//这个问题可以通过添加-pthread
切换到g++
来解决。也许可以看看这个:@Anders K::这在这里似乎没有任何用处。如果默认的启动策略没有崩溃,我会对它感到满意。