diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 9b3a5effe..fdf0bf5f6 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -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; diff --git a/test/teststl.cpp b/test/teststl.cpp index b4d686229..0caa695a0 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -854,6 +854,12 @@ private: " return d;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + checkNormal("std::string f() {\n" + " std::map m = { { 1, \"1\" } };\n" + " return m.at(1);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void outOfBoundsSymbolic()