diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 93f2f3c7c..bf4c3487d 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5736,8 +5736,11 @@ struct ContainerVariableAnalyzer : VariableAnalyzer { } } else if (Token::Match(tok, "%name% . %name% (")) { Library::Container::Action action = tok->valueType()->container->getAction(tok->strAt(2)); - if (action == Library::Container::Action::PUSH || action == Library::Container::Action::POP) - return Action::Read | Action::Write | Action::Incremental; + if (action == Library::Container::Action::PUSH || action == Library::Container::Action::POP) { + std::vector args = getArguments(tok->tokAt(3)); + if (args.size() < 2) + return Action::Read | Action::Write | Action::Incremental; + } } return Action::None; } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index ce53e5895..8cd4cfd6f 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -5025,6 +5025,15 @@ private: " }\n" "}\n"; ASSERT_EQUALS(true, testValueOfXKnown(code, 4U, 0)); + + code = "std::vector g();\n" + "int f(bool b) {\n" + " std::set a;\n" + " std::vector c = g();\n" + " a.insert(c.begin(), c.end());\n" + " return a.size();\n" + "}\n"; + ASSERT_EQUALS(true, tokenValues(code, "a . size", ValueFlow::Value::ValueType::CONTAINER_SIZE).empty()); } void valueFlowDynamicBufferSize() {