diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 207458b3f..52ff2b449 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1361,7 +1361,8 @@ void CheckClass::checkMemset() if (numIndirToVariableType == 1) type = var->typeScope(); - if (!type && !var->isPointer() && mSettings->library.detectContainerOrIterator(var->typeStartToken())) { + if (!type && !var->isPointer() && !Token::simpleMatch(var->typeStartToken(), "std :: array") && + mSettings->library.detectContainerOrIterator(var->typeStartToken())) { memsetError(tok, tok->str(), var->getTypeName(), {}, /*isContainer*/ true); } } diff --git a/test/testclass.cpp b/test/testclass.cpp index e0bf7916a..6967e685a 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -3146,6 +3146,12 @@ private: " f

(Dst, Src, 2);\n" "}\n", s); ASSERT_EQUALS("", errout.str()); + + checkNoMemset("void f() {\n" + " std::array a;\n" + " std::memset(&a, 0, 4);\n" + "}\n", s); + ASSERT_EQUALS("", errout.str()); } void memsetOnInvalid() { // Ticket #5425