Fix 11011: FP returnDanglingLifetime with non-const reference argument [inconclusive] (#4066)
* Fix 11011: FP returnDanglingLifetime with non-const reference argument [inconclusive] * Format
This commit is contained in:
parent
6a914dc435
commit
9fa5c4e201
|
@ -3930,7 +3930,7 @@ static void valueFlowLifetimeConstructor(Token* tok,
|
|||
else
|
||||
ls.byVal(tok, tokenlist, errorLogger, settings);
|
||||
});
|
||||
} else {
|
||||
} else if (!constructor->nestedIn->varlist.empty()) {
|
||||
LifetimeStore::forEach(args,
|
||||
"Passed to constructor of '" + name + "'.",
|
||||
ValueFlow::Value::LifetimeKind::SubObject,
|
||||
|
|
|
@ -3259,6 +3259,16 @@ private:
|
|||
ASSERT_EQUALS(
|
||||
"[test.cpp:8] -> [test.cpp:7] -> [test.cpp:8]: (error) Returning object that points to local variable 'files' that will be invalid when returning.\n",
|
||||
errout.str());
|
||||
|
||||
check("struct S {\n"
|
||||
" explicit S(std::string& s);\n"
|
||||
"}\n"
|
||||
"S f() {\n"
|
||||
" std::string m(\"abc\");\n"
|
||||
" return S(m);\n"
|
||||
"}\n",
|
||||
true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetimeAggegrateConstructor() {
|
||||
|
|
Loading…
Reference in New Issue