Fix FP containerOutOfBounds with std::map (#4230)

This commit is contained in:
chrchr-github 2022-06-23 20:26:47 +02:00 committed by GitHub
parent f1212e66f7
commit 60c1eef659
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -128,7 +128,7 @@ void CheckStl::outOfBounds()
for (const Scope *function : mTokenizer->getSymbolDatabase()->functionScopes) {
for (const Token *tok = function->bodyStart; tok != function->bodyEnd; tok = tok->next()) {
const Library::Container *container = getLibraryContainer(tok);
if (!container)
if (!container || container->stdAssociativeLike)
continue;
const Token * parent = astParentSkipParens(tok);
const Token* accessTok = parent;

View File

@ -854,6 +854,12 @@ private:
" return d;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkNormal("std::string f() {\n"
" std::map<int, std::string> m = { { 1, \"1\" } };\n"
" return m.at(1);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void outOfBoundsSymbolic()