diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 263b6d585..43dd2f97e 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3854,7 +3854,7 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog valueFlowLifetimeFunction(parent->previous(), tokenlist, errorLogger, settings); valueFlowForwardLifetime(parent, tokenlist, errorLogger, settings); // Variable - } else if (tok->variable()) { + } else if (tok->variable() && tok->variable()->scope()) { const Variable *var = tok->variable(); const Token *endOfVarScope = var->scope()->bodyEnd; diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 26f828d13..890c9674c 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -6896,6 +6896,11 @@ private: " const C& c = C(b) ? : C(false);\n" "};\n"; valueOfTok(code, "?"); + + code = "struct S {\n" + " void g(std::vector (*f) () = nullptr);\n" + "};\n"; + valueOfTok(code, "="); } void valueFlowHang() {