This is a followup bug of #90274.
The following code snippet should generate bugprone-return-const-ref-from-parameter error but clang-tidy doesn't:
#include <string>
struct Foo {
const std::string &f(const std::string &a) const {
return a;
}
void f(std::string&&) = delete;
};
The following bug-prone usage compiles:
int main() {
const Foo foo;
auto& a = foo.f(std::string("12"));
// use a...
return 0;
}
The proper way to avoid this clang-tidy warning is to overload with the same constness:
#include <string>
struct Foo {
const std::string &f(const std::string &a) const {
return a;
}
void f(std::string&&) const = delete;
};