Skip to content

task: co_return with_error(...) & with_stopped - #2154

Open
RobertLeahy wants to merge 3 commits into
NVIDIA:mainfrom
RobertLeahy:p4282_20260801
Open

task: co_return with_error(...) & with_stopped#2154
RobertLeahy wants to merge 3 commits into
NVIDIA:mainfrom
RobertLeahy:p4282_20260801

Conversation

@RobertLeahy

@RobertLeahy RobertLeahy commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Two bugfixes and implementation of of P4282R1 Away From co_yield For
std::execution::task
.

Note that newly-added co_return functionality for task<void> requires a compiler which provides P3950R1 return_value & return_void Are Not Mutually Exclusive.

The standard specifies that std::execution::task shall destroy the
coroutine frame before sending set_stopped to the receiver in the case
of unhandled_stopped:

  The asynchronous operation is completed by first destroying the
  coroutine frame [...] and then invoking set_stopped(std::move(
  st.rcvr)).

STDEXEC::task previously belied this, instead destroying the coroutine
frame sometime after the dispatch of set_stopped.

Added a reproducing unit test and corrected.
The standard specifies that co_yield with_error(e) is valid if e is
convertible to one of the task's error types:

  Mandates: std::move(err.error) is convertible to exactly one of the
  set_error_t argument types of error_types.

STDEXEC::task previously belied this instead requiring that e be exactly
one of the error types (rather than convertible to exactly one such
type).

Fixed and added a reproducing unit test.
@copy-pr-bot

copy-pr-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Comment thread include/stdexec/__detail/__config.hpp Outdated
@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test fdf37b8

Implemented P4282 by enhancing task as follows:

- co_yield can now be used directly to send set_stopped using the new
  with_stopped tag
- co_return can now be used with with_error and with_stopped to send
  set_error or set_stopped, respectively

Note that the co_return functionality requires a compiler which
implements P3950 (adopted into the C++29 working draft in Brno) when
used with a task<void>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants