Fixed #9434 (False positive: Out of bounds access when using const pointer)

This commit is contained in:
Daniel Marjamäki 2019-12-15 20:10:12 +01:00
parent 88a3b4c685
commit a241be0ecc
2 changed files with 11 additions and 1 deletions

View File

@ -5423,7 +5423,9 @@ static bool isContainerSizeChangedByFunction(const Token *tok, int depth = 20)
if (arg) {
if (!arg->isReference() && !addressOf)
return false;
if (arg->isConst())
if (!addressOf && arg->isConst())
return false;
if (arg->valueType() && arg->valueType()->constness == 1)
return false;
const Scope * scope = fun->functionScope;
if (scope) {

View File

@ -4077,6 +4077,14 @@ private:
"}";
ASSERT(tokenValues(code, "x . front").empty());
code = "void g(std::list<int>* const);\n" // #9434
"void f() {\n"
" std::list<int> x;\n"
" g(&x);\n"
" x.front();\n"
"}";
ASSERT(tokenValues(code, "x . front").empty());
code = "void g(const std::list<int>&);\n"
"void f() {\n"
" std::list<int> x;\n"