diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 93f34f309..42866e137 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1270,9 +1270,8 @@ static void valueFlowPointerAliasDeref(TokenList *tokenlist) if (!var->isConst() && isVariableChanged(lifeTok->next(), tok, lifeTok->varId(), !var->isLocal(), tokenlist->getSettings(), tokenlist->isCPP())) continue; for (const ValueFlow::Value& v:lifeTok->values()) { - // TODO: Move container size values to generic forward // Forward uninit values since not all values can be forwarded directly - if (!(v.isContainerSizeValue() || v.isUninitValue())) + if (!v.isUninitValue()) continue; ValueFlow::Value value = v; value.errorPath.insert(value.errorPath.begin(), errorPath.begin(), errorPath.end()); diff --git a/test/teststl.cpp b/test/teststl.cpp index 369beeb6d..bc522ef80 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -430,6 +430,16 @@ private: " v[0] = 1;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + checkNormal("void foo(std::vector* PArr, int n) {\n" + " std::vector Arr;\n" + " if (!PArr)\n" + " PArr = &Arr;\n" + " PArr->resize(n);\n" + " for (int i = 0; i < n; ++i)\n" + " (*PArr)[i] = 1;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void outOfBoundsIndexExpression() {