What is wrong with the following code? When ran the program aborts with an unknown exception
#include <iostream>
#include <future>
int main() {
auto promise = std::promise<int>{};
auto future_one = promise.get_future();
promise.set_value(1);
return 0;
}
The error output is
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
Aborted (core dumped)
g++ --version for me gives
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The same code works just fine on a mac
Note The line of code that the exception originates from is the promise.set_value(1)