Fix 10425: False positive: returnDanglingLifetime when taking address of captured variable (#3415)
This commit is contained in:
parent
5868d01e80
commit
8ddc5764f8
|
@ -3839,6 +3839,7 @@ static void valueFlowLifetime(TokenList *tokenlist, SymbolDatabase*, ErrorLogger
|
|||
tok2, "Lambda captures variable by value here.", ValueFlow::Value::LifetimeKind::Lambda};
|
||||
ls.forward = false;
|
||||
update |= ls.byVal(tok, tokenlist, errorLogger, settings, pred);
|
||||
pred(tok2);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2037,6 +2037,18 @@ private:
|
|||
" };\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct A {\n"
|
||||
" int x;\n"
|
||||
"};\n"
|
||||
"auto f() {\n"
|
||||
" A a;\n"
|
||||
" return [=] {\n"
|
||||
" const A* ap = &a;\n"
|
||||
" ap->x;\n"
|
||||
" };\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetimeContainer() {
|
||||
|
|
Loading…
Reference in New Issue