Fixed #5481: std::array is POD, so using memcpy (etc.) is allowed on it.

This commit is contained in:
PKEuS 2014-03-16 19:55:32 +01:00
parent 80b1271d01
commit 1e57f54917
2 changed files with 10 additions and 1 deletions

View File

@ -1054,7 +1054,7 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
const Scope *typeScope = var->typeScope();
// check for std:: type
if (var->isStlType())
if (var->isStlType() && tok1->strAt(2) != "array")
if (allocation)
mallocOnClassError(tok, tok->str(), type->classDef, "'std::" + tok1->strAt(2) + "'");
else

View File

@ -2507,6 +2507,15 @@ private:
"[test.cpp:11]: (error) Using 'memset' on struct that contains a 'std::string'.\n"
"[test.cpp:12]: (error) Using 'memset' on struct that contains a 'std::string'.\n"
"[test.cpp:13]: (error) Using 'memset' on struct that contains a 'std::string'.\n", errout.str());
checkNoMemset("class A {\n"
" std::array<int, 10> ints;\n"
"};\n"
"void f() {\n"
" A a;\n"
" memset(&a, 0, sizeof(A));\n"
"}");
ASSERT_EQUALS("", errout.str()); // std::array is POD (#5481)
}
void mallocOnClass() {