This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/80316] New: std::promise treats no shared state as undefined


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]