Skip to content

Constrain completion CPOs to non-const rvalue receivers - #2311

Open
emmett2020 wants to merge 4 commits into
NVIDIA:mainfrom
emmett2020:fix/completion-cpo-receiver-constraints
Open

emmett2020 wants to merge 4 commits into
NVIDIA:mainfrom
emmett2020:fix/completion-cpo-receiver-constraints

Conversation

@emmett2020

@emmett2020 emmett2020 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

The standard requires calls to set_value, set_error, and set_stopped to be ill-formed when the receiver is an lvalue or a const rvalue. The current implementations only check member callability and do not enforce these restrictions. This change adds the missing constraints and corresponding tests.

The stricter constraints expose existing lvalue completion calls in parallel_scheduler and merge_each. The scheduler now passes its receiver as an rvalue. In merge_each, the next-sequence operation now stores a decayed receiver type to allow rvalue completion and avoid retaining a dangling reference:

auto subscribe(auto receiver) &&
{
  return ex::connect(next_sender, receiver);
  // Before: operation stores R&; completion cpo receives an lvalue.
  // After:  operation stores R; completion cpo receives an rvalue.
} // Storing R& also leaves a dangling reference to this local receiver.

This MR also includes 4 unrelated formatting-only line changes required to pass the CI clang-format 21 check.

Update receiver tests and fix affected calls in parallel_scheduler
and receiver storage in merge_each.
@copy-pr-bot

copy-pr-bot Bot commented Oct 7, 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.

@emmett2020 emmett2020 changed the title Reject lvalue and const receivers in completion CPOs Constrain completion CPOs to non-const rvalue receivers Oct 7, 2026
Comment thread include/stdexec/__detail/__receivers.hpp Outdated

This branch has not been deployed

No deployments
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