| Issue |
174826
|
| Summary |
[clang-tidy] performance-move-const-arg incorrectly removes move with private copy constructor
|
| Labels |
clang-tidy
|
| Assignees |
|
| Reporter |
R-Goc
|
On a type with a private copy constructor that is trivially copyable, performance-move-const-arg will remove the move, thus causing a compilation error.
```cpp
#include <utility>
class Error {
public:
static Error from_errno(int code)
{
return Error(code);
}
Error(Error&&) = default;
Error& operator=(Error&&) = default;
private:
Error(int code)
: m_code(code)
{
}
Error(Error const&) = default;
Error& operator=(Error const&) = default;
int m_code { 0 };
};
struct A {
Error error;
};
static A func()
{
auto error = Error::from_errno(123);
return A { .error = std::move(error) };
}
```
Godbolt link: https://godbolt.org/z/8683WEGP4
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs