Skip to content

bugprone-move-forwarding-reference#9526

Merged
Jacobfaib merged 1 commit into
NVIDIA:mainfrom
Jacobfaib:jacobf/2026-06-17/bugprone-move-forwarding-reference
Jun 23, 2026
Merged

bugprone-move-forwarding-reference#9526
Jacobfaib merged 1 commit into
NVIDIA:mainfrom
Jacobfaib:jacobf/2026-06-17/bugprone-move-forwarding-reference

Conversation

@Jacobfaib

Copy link
Copy Markdown
Contributor

Description

closes

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@Jacobfaib Jacobfaib self-assigned this Jun 17, 2026
@Jacobfaib Jacobfaib requested a review from a team as a code owner June 17, 2026 17:41
@Jacobfaib Jacobfaib requested a review from gevtushenko June 17, 2026 17:41
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 17, 2026
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 21f0ab45-544a-4113-a2ef-41537eeed648

📥 Commits

Reviewing files that changed from the base of the PR and between 5ba76c7 and 4b6a63f.

📒 Files selected for processing (2)
  • .clang-tidy
  • thrust/thrust/detail/allocator_aware_execution_policy.h
💤 Files with no reviewable changes (1)
  • .clang-tidy

Note: CodeRabbit is enabled on this repository as a convenience for maintainers
and contributors. Use your best judgment when considering its review comments and
suggestions — a suggested change may be inadequate, unnecessary, or safe to ignore.
Contributors are not expected to address every comment. Human reviews are what
ultimately matter for merging.

Summary

This PR fixes a code correctness issue related to the improper use of std::move with forwarding references and enables the corresponding clang-tidy diagnostic to prevent similar issues in the future.

Changes Made

.clang-tidy

  • Enabled the bugprone-move-forwarding-reference clang-tidy check by including it in the enabled checks list without exclusion. This diagnostic detects cases where std::move is incorrectly used with forwarding references, which can lead to incorrect semantics.

thrust/thrust/detail/allocator_aware_execution_policy.h

  • Updated the include directive to use cuda/std/__utility/forward.h instead of cuda/std/__utility/move.h
  • Fixed the rvalue reference overload of operator()(Allocator&&) to use cuda::std::forward<Allocator>(alloc) instead of cuda::std::move(alloc). This is the correct pattern for forwarding references, as it properly preserves the value category of the original argument (whether it's an lvalue or rvalue).

Rationale

When a template parameter is deduced as a forwarding reference (e.g., Allocator&& where Allocator is a template parameter), using std::forward instead of std::move ensures proper value category semantics. The std::move utility unconditionally casts to an rvalue reference, which can lead to unexpected behavior when the original argument is an lvalue reference, whereas std::forward correctly preserves the original reference type.

Walkthrough

allocator_aware_execution_policy's rvalue operator()(Allocator&&) previously called cuda::std::move(alloc) on a forwarding reference, which is incorrect. The fix replaces move with cuda::std::forward<Allocator> and swaps the move.h include for forward.h. The -bugprone-move-forwarding-reference suppression is then removed from .clang-tidy.

Changes

Forwarding-reference fix and lint re-enablement

Layer / File(s) Summary
Switch allocator operator to perfect-forward
thrust/thrust/detail/allocator_aware_execution_policy.h
Includes forward.h instead of move.h; changes operator()(Allocator&&) body from cuda::std::move(alloc) to cuda::std::forward<Allocator>(alloc).
Re-enable clang-tidy check
.clang-tidy
Removes -bugprone-move-forwarding-reference from the disabled checks list now that the triggering code is fixed.

Possibly related PRs

  • NVIDIA/cccl#9467: Modifies .clang-tidy bugprone-* configuration — enables bugprone-* broadly and selectively disables specific checks, directly overlapping with this PR's removal of the bugprone-move-forwarding-reference suppression.

Suggested reviewers

  • bernhardmgruber

Comment @coderabbitai help to get the list of available commands and usage tips.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jun 17, 2026
@github-actions

This comment has been minimized.

@Jacobfaib Jacobfaib force-pushed the jacobf/2026-06-17/bugprone-move-forwarding-reference branch from a068d19 to 4b6a63f Compare June 22, 2026 12:41
@github-actions

This comment has been minimized.

@Jacobfaib Jacobfaib enabled auto-merge (squash) June 23, 2026 13:23
@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1d 02h: Pass: 100%/119 | Total: 5d 00h | Max: 2h 58m | Hits: 23%/853302

See results here.

@Jacobfaib Jacobfaib merged commit bbe2293 into NVIDIA:main Jun 23, 2026
264 of 275 checks passed
@Jacobfaib Jacobfaib deleted the jacobf/2026-06-17/bugprone-move-forwarding-reference branch June 23, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants