Skip to content

[Clang-Tidy] cppcoreguidelines-rvalue-reference-param-not-moved false positive on rvalue references since C++20 #132419

Open
@MagentaTreehouse

Description

@MagentaTreehouse

Given this code:

struct A {
    A(A &&) = default;
    A &operator=(A &&) = default;
};

A f(A &&a) {
    return a;
}

Even in C++20, Clang-Tidy says:

<source>:6:9: warning: rvalue reference parameter 'a' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
    6 | A f(A &&a) {
      |         ^

Seems like P1825 is not fully implemented in this check.

See https://compiler-explorer.com/z/47o1jdnx8.

Activity

llvmbot

llvmbot commented on Mar 21, 2025

@llvmbot
Member

@llvm/issue-subscribers-clang-tidy

Author: None (MagentaTreehouse)

Given this code: ```c++ struct A { A(A &&) = default; A &operator=(A &&) = default; };

A f(A &&a) {
return a;
}


Even in C++20, Clang-Tidy says:
```console
&lt;source&gt;:6:9: warning: rvalue reference parameter 'a' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
    6 | A f(A &amp;&amp;a) {
      |         ^

Seems like P1825 is not fully implemented in this check.

See https://compiler-explorer.com/z/47o1jdnx8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @llvmbot@MagentaTreehouse

        Issue actions

          [Clang-Tidy] `cppcoreguidelines-rvalue-reference-param-not-moved` false positive on rvalue references since C++20 · Issue #132419 · llvm/llvm-project