diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index cc093d5b2..1d663c494 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -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); } }; diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index e0552558c..83ee2487d 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -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() {