This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/80316] New: std::promise treats no shared state as undefined
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 04 Apr 2017 17:11:22 +0000
- Subject: [Bug libstdc++/80316] New: std::promise treats no shared state as undefined
- Auto-submitted: auto-generated
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.