Issue 164735
Summary cppcoreguidelines-rvalue-reference-param-not-moved false positive on dependent type
Labels false-positive
Assignees
Reporter jordan-woyak
    The following code demonstrates the issue:
```cpp
#include <memory>
#include <utility>

template <typename T>
struct Holder
{
    std::decay_t<T> value;
    explicit Holder(T&& v) : value{std::forward<T>(v)} {};
};

template <typename T>
Holder(T&&) -> Holder<T>;

int main()
{
    std::unique_ptr<int> x{};
    Holder uptr_holder(std::move(x));

    int y{};
    Holder int_holder(y);
}

```

This produces a clang-tidy warning on the `Holder` constructor:
```
Rvalue reference parameter 'v' is never moved from inside the function body clang-tidy(cppcoreguidelines-rvalue-reference-param-not-moved)
```

`cppcoreguidelines-rvalue-reference-param-not-moved` fails to recognize that `T` may be something like `int&`, making `T&&` also `int&`, and not actually an rvalue reference.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to