[Bug libstdc++/80316] New: std::promise treats no shared state as undefined
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Apr 4 17:11:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80316
Bug ID: 80316
Summary: std::promise treats no shared state as undefined
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
This segfaults:
#include <future>
int main()
{
std::promise<int> p;
std::promise<int> q(std::move(p));
p.set_exception_at_thread_exit(std::make_exception_ptr(1));
}
The spec for set_exception_at_thread_exit is clear:
Throws: future_error if an error condition occurs.
Error conditions:
— promise_already_satisfied if its shared state already has a stored value or
exception.
— no_state if *this has no shared state.
We also segfault for any of:
p.set_value(1);
p.set_value_at_thread_exit(1);
p.set_exception(std::make_exception_ptr(1));
It's not clear whether these are undefined, but I'll create a DR for that.
More information about the Gcc-bugs
mailing list