diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 72da844aa87..8ed603284c5 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3017,6 +3017,8 @@ static void valueFlowLifetimeFunction(Token *tok, const TokenList &tokenlist, Er // TODO: Propagate lifetimes with library functions if (settings.library.getFunction(tok->previous())) return; + if (Token::simpleMatch(tok->astParent(), ".")) + return; // Assume constructing the valueType valueFlowLifetimeConstructor(tok->next(), tokenlist, errorLogger, settings); valueFlowForwardLifetime(tok->next(), tokenlist, errorLogger, settings); diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 58bf423dadd..d9d0e8cb190 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -3504,6 +3504,13 @@ class TestAutoVariables : public TestFixture { " return par;\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("struct S { int* (*ptr)(const int*); };\n" // #13057 + "int* f(S* s) {\n" + " int x = 0;\n" + " return s->ptr(&x);\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void danglingLifetimeUserConstructor()