Fix 10308: danglingTemporaryLifetime confused by function parameter (#3292)
This commit is contained in:
parent
f3a33ea330
commit
f55a4563f9
|
@ -570,7 +570,7 @@ static void setTokenValue(Token* tok, ValueFlow::Value value, const Settings* se
|
|||
if (value.lifetimeKind == ValueFlow::Value::LifetimeKind::Iterator && astIsIterator(parent)) {
|
||||
setTokenValue(parent,value,settings);
|
||||
} else if (astIsPointer(tok) && astIsPointer(parent) &&
|
||||
(parent->isArithmeticalOp() || Token::Match(parent, "( %type%"))) {
|
||||
(parent->isArithmeticalOp() || parent->isCast())) {
|
||||
setTokenValue(parent,value,settings);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -2927,6 +2927,19 @@ private:
|
|||
" return state;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct var {\n"
|
||||
" void fun();\n"
|
||||
"}x;\n"
|
||||
"var* T(const char*) {\n"
|
||||
" return &x;\n"
|
||||
"}\n"
|
||||
"std::string GetTemp();\n"
|
||||
"void f() {\n"
|
||||
" auto a = T(GetTemp().c_str());\n"
|
||||
" a->fun();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void invalidLifetime() {
|
||||
|
|
Loading…
Reference in New Issue