Skip to content

fix(stdexec): silence unused-parameter warning in __fuse_token_fn - #2287

Merged
ericniebler merged 1 commit into
NVIDIA:mainfrom
alwaysprince05:fix/stop-when-unused-param
Sep 25, 2026
Merged

ericniebler merged 1 commit into
NVIDIA:mainfrom
alwaysprince05:fix/stop-when-unused-param

Conversation

@alwaysprince05

Copy link
Copy Markdown
Contributor

Problem

Including <stdexec/execution.hpp> fails to compile on recent clang versions (e.g. Apple clang 21, Xcode 26) when the user builds with -Wall -Wextra -Werror:

In file included from repro.cpp:1:
include/stdexec/__detail/__stop_when.hpp:137:60: error: unused parameter '__rcvr_token' [-Werror,-Wunused-parameter]
  137 |       operator()(_SenderToken __sndr_token, _ReceiverToken __rcvr_token) const noexcept
      |                                                            ^
1 error generated.

Minimal repro (compiles with no stdexec API in use at all):

#include "stdexec/execution.hpp"
int main() {}
clang++ -std=c++20 -I include -Wall -Wextra -Werror -c repro.cpp

Root cause

The unstoppable-token overload of __fuse_token_fn::operator() in __stop_when.hpp takes the receiver's stop token but intentionally ignores it — when the receiver's token is unstoppable, the net token is just the sender's captured token. Because it is an uninstantiated function template at header-parse time, clang (unlike GCC) still diagnoses the unused parameter, and -Wunused-parameter is part of -Wextra.

CI misses this because add_compile_diagnostics() applies -Wall -Wextra -Wpedantic -Werror only for Clang/GNU CMake compiler IDs — not AppleClang — and the Linux clang versions used in CI don't fire the diagnostic for this template. macOS users on Xcode 26 toolchains hit it immediately.

A whole-tree scan with Apple clang 21 (-Wall -Wextra -Werror) shows this is the only remaining such warning across all public headers; every other #include compiles clean.

Fix

Mark the intentionally-unused parameter [[maybe_unused]], consistent with the existing convention in the codebase (e.g. exec/static_thread_pool.hpp, exec/sequence_senders.hpp, nvexec). No behavioral change.

Verification

  • The minimal repro above now compiles clean with -Wall -Wextra -Werror on Apple clang 21 (Apple clang version 21.0.0); A/B-verified against pristine main.
  • Whole-tree scan: all public headers (stdexec/execution.hpp, functional.hpp, coroutine.hpp, stop_token.hpp, concepts.hpp) compile warning-free with -Wall -Wextra -Werror on Apple clang 21.
  • test.stdexec: all tests pass (623 test cases / 3536 assertions), normal configuration.
  • test.exec: all tests pass (365 test cases / 3438 assertions), normal configuration.
  • Same two suites built and run with STDEXEC_ENABLE_EXTRA_TYPE_CHECKING=ON: all pass, identical counts — no interaction with the debug-connect machinery.
  • clang-format --dry-run --Werror (clang-format 21) passes on the touched file.

The unstoppable-token overload of __fuse_token_fn::operator() takes the
receiver's stop token but intentionally ignores it (the net token is just
the sender's captured token. Mark the parameter [[maybe_unused]] so that
including <stdexec/execution.hpp> compiles cleanly with -Wall -Wextra
-Werror on recent clang versions (e.g. Apple clang 21), where the warning
fires on the uninstantiated template during header parsing.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
EOF
)
@copy-pr-bot

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

@alwaysprince05

Copy link
Copy Markdown
Contributor Author

/ok to test

@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test 2ec64ce

@ericniebler
ericniebler merged commit ead186b into NVIDIA:main Sep 25, 2026
39 checks passed
@ericniebler

Copy link
Copy Markdown
Collaborator

thanks

@alwaysprince05
alwaysprince05 deleted the fix/stop-when-unused-param branch September 25, 2026 08:26
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