Dont diagnose impossible values for iterators (#2755)
This commit is contained in:
parent
31d7acb99a
commit
46bf2d7d52
|
@ -2025,6 +2025,8 @@ void CheckStl::checkDereferenceInvalidIterator2()
|
|||
|
||||
// Can iterator point to END or before START?
|
||||
for (const ValueFlow::Value& value:tok->values()) {
|
||||
if (value.isImpossible())
|
||||
continue;
|
||||
if (!printInconclusive && value.isInconclusive())
|
||||
continue;
|
||||
if (!value.isIteratorValue())
|
||||
|
|
|
@ -3571,6 +3571,12 @@ private:
|
|||
" *(i-1)=0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (warning) Possible dereference of an invalid iterator: i-1\n", errout.str());
|
||||
|
||||
check("int f(std::vector<int> v, int pos) {\n"
|
||||
" if (pos >= 0)\n"
|
||||
" return *(v.begin() + pos);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void dereferenceInvalidIterator2() {
|
||||
|
|
Loading…
Reference in New Issue