The following cpp code doesn't run on Ubuntu 13.10 using g++-4.8 or g++-4.7. I have no idea how to solve that issue. It seems that on older Ubuntu versions (e.g. 13.04) the code below works fine.
#include <future>
#include <iostream>
int main(int argc, char** argv)
{
int step = 0;
std::cout << "step " << ++step << std::endl;
std::promise<int> promise;
std::cout << "step " << ++step << std::endl;
try
{
promise.set_value(42);
std::cout << "step " << ++step << std::endl;
}
catch (const std::system_error& ex)
{
std::cout << "Exception: " << ex.what() << "\n";
}
}
g++ promise_test.cpp -o promise_test -pthread -std=c++11 && ./promise_test
step 1
step 2
Exception: Unknown error -1
The bug report. The work around provided is -Wl,--no-as-needed. See this other question.
As an alternative we fixed it with -static-libstdc++ flag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With