diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 36f67d7536c..2232c2be61f 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -673,7 +673,7 @@ void CheckFunctions::returnLocalStdMove() const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase(); for (const Scope *scope : symbolDatabase->functionScopes) { // Expect return by-value - if (Function::returnsReference(scope->function, true)) + if (Function::returnsReference(scope->function, /*unknown*/ true, /*includeRValueRef*/ true)) continue; const auto rets = Function::findReturns(scope->function); for (const Token* ret : rets) { diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 13589ac1386..8eacf8b1c1b 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1808,6 +1808,12 @@ class TestFunctions : public TestFixture { " std::cout << p->msg;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("std::string&& f() {\n" // #11881 + " std::string s;\n" + " return std::move(s);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void negativeMemoryAllocationSizeError() { // #389