Open
Description
struct A {
explicit A(int) {
}
A& operator=(int n) {
// ok, no clang-tidy warning as expected.
return *this = A(n);
}
};
template<typename T>
struct B {
explicit B(int) {
}
B& operator=(int n) {
// clang-tidy warning: Operator=() should always return '*this'
// clang-tidy rule: misc-unconventional-assign-operator
// clang-tidy rule: cppcoreguidelines-c-copy-assignment-signature
return *this = B(n);
}
};
clang-tidy version: 20.1.5.
This false positive will only be triggered for template classes; It doesn't occur for non-template classes.