Fix 10467: FP mismatchingContainers with array of vectors (#3453)
This commit is contained in:
parent
b0b3f7ec2d
commit
9ece849d80
|
@ -3621,11 +3621,17 @@ static void valueFlowLifetimeFunction(Token *tok, TokenList *tokenlist, ErrorLog
|
||||||
if (i->container != returnContainer)
|
if (i->container != returnContainer)
|
||||||
continue;
|
continue;
|
||||||
const Token * const argTok = args[argnr - 1];
|
const Token * const argTok = args[argnr - 1];
|
||||||
|
bool forward = false;
|
||||||
|
for (ValueFlow::Value val : argTok->values()) {
|
||||||
|
if (!val.isLifetimeValue())
|
||||||
|
continue;
|
||||||
|
val.errorPath.emplace_back(argTok, "Passed to '" + tok->str() + "'.");
|
||||||
|
setTokenValue(tok->next(), val, settings);
|
||||||
|
forward = true;
|
||||||
|
}
|
||||||
// Check if lifetime is available to avoid adding the lifetime twice
|
// Check if lifetime is available to avoid adding the lifetime twice
|
||||||
ValueFlow::Value val = getLifetimeObjValue(argTok);
|
if (forward) {
|
||||||
if (val.tokvalue) {
|
valueFlowForwardLifetime(tok, tokenlist, errorLogger, settings);
|
||||||
LifetimeStore{argTok, "Passed to '" + tok->str() + "'.", ValueFlow::Value::LifetimeKind::Iterator}.byVal(
|
|
||||||
tok->next(), tokenlist, errorLogger, settings);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1704,6 +1704,16 @@ private:
|
||||||
" if (c.end() == d.end()) {}\n"
|
" if (c.end() == d.end()) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #10467
|
||||||
|
check("void f(std::array<std::vector<int>, N>& A) {\n"
|
||||||
|
" for (auto& a : A) {\n"
|
||||||
|
" auto it = std::find_if(a.begin(), a.end(), \n"
|
||||||
|
" [](auto i) { return i == 0; });\n"
|
||||||
|
" if (it != a.end()) {}\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dereferencing invalid pointer
|
// Dereferencing invalid pointer
|
||||||
|
|
Loading…
Reference in New Issue