diff --git a/cfg/std.cfg b/cfg/std.cfg
index 35dcb8796..c2c9c2008 100644
--- a/cfg/std.cfg
+++ b/cfg/std.cfg
@@ -7536,4 +7536,41 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp
index 4f3b4aee4..b1d75108c 100644
--- a/lib/checkclass.cpp
+++ b/lib/checkclass.cpp
@@ -1135,7 +1135,6 @@ void CheckClass::checkMemset()
// 3 arguments.
continue;
-
const Token *typeTok = nullptr;
const Scope *type = nullptr;
if (Token::Match(arg3, "sizeof ( %type% ) )"))
@@ -1237,12 +1236,23 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
const Token *tok1 = var.typeStartToken();
const Scope *typeScope = var.typeScope();
+ std::string typeName;
+ if (Token::Match(tok1, "%type% ::")) {
+ const Token *typeTok = tok1;
+ while (Token::Match(typeTok, "%type% ::")) {
+ typeName += typeTok->str() + "::";
+ typeTok = typeTok->tokAt(2);
+ }
+ typeName += typeTok->str();
+ }
+
// check for std:: type
- if (var.isStlType() && tok1->strAt(2) != "array" && !mSettings->library.podtype(tok1->strAt(2)))
+ if (var.isStlType() && typeName != "std::array" && !mSettings->library.podtype(typeName)) {
if (allocation)
- mallocOnClassError(tok, tok->str(), type->classDef, "'std::" + tok1->strAt(2) + "'");
+ mallocOnClassError(tok, tok->str(), type->classDef, "'" + typeName + "'");
else
- memsetError(tok, tok->str(), "'std::" + tok1->strAt(2) + "'", type->classDef->str());
+ memsetError(tok, tok->str(), "'" + typeName + "'", type->classDef->str());
+ }
// check for known type
else if (typeScope && typeScope != type)
diff --git a/test/testclass.cpp b/test/testclass.cpp
index 1bdf51587..6009576b9 100644
--- a/test/testclass.cpp
+++ b/test/testclass.cpp
@@ -3144,7 +3144,8 @@ private:
Settings settings;
const char xmldata[] = "\n"
"\n"
- " \n"
+ " \n"
+ " \n"
"";
tinyxml2::XMLDocument doc;
doc.Parse(xmldata, sizeof(xmldata));
@@ -3161,8 +3162,7 @@ private:
checkNoMemset("struct st {\n"
" std::uint8_t a;\n"
- " std::uint8_t b;\n"
- " std::uint8_t c;\n"
+ " std::atomic_bool b;\n"
"};\n"
"\n"
"void f() {\n"