Fix memsetClass FP (#4465)
This commit is contained in:
parent
f1aa9eb48f
commit
c9ade33298
|
@ -1354,7 +1354,7 @@ void CheckClass::checkMemset()
|
|||
if (numIndirToVariableType == 1)
|
||||
type = var->typeScope();
|
||||
|
||||
if (!type && mSettings->library.detectContainerOrIterator(var->typeStartToken())) {
|
||||
if (!type && !var->isPointer() && mSettings->library.detectContainerOrIterator(var->typeStartToken())) {
|
||||
memsetError(tok, tok->str(), var->getTypeName(), {}, /*isContainer*/ true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3119,6 +3119,18 @@ private:
|
|||
" memcpy(&s, c, strlen(c) + 1);\n"
|
||||
"}\n", s);
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Using 'memcpy' on std::string.\n", errout.str());
|
||||
|
||||
checkNoMemset("template <typename T>\n"
|
||||
" void f(T* dst, const T* src, int N) {\n"
|
||||
" std::memcpy(dst, src, N * sizeof(T));\n"
|
||||
"}\n"
|
||||
"void g() {\n"
|
||||
" typedef std::vector<int>* P;\n"
|
||||
" P Src[2]{};\n"
|
||||
" P Dst[2];\n"
|
||||
" f<P>(Dst, Src, 2);\n"
|
||||
"}\n", s);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void memsetOnInvalid() { // Ticket #5425
|
||||
|
|
Loading…
Reference in New Issue