Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1675,18 +1675,9 @@ void CheckClassImpl::checkMemsetType(const Scope *start, const Token *tok, const
}
// don't warn if variable static or const, pointer or array of pointers
if (!var.isStatic() && !var.isConst() && !var.isPointer() && (!var.isArray() || var.typeEndToken()->str() != "*")) {
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();
}
const std::string typeName = var.getTypeName();

// check for std:: type
if (var.isStlType() && typeName != "std::array" && !mSettings.library.podtype(typeName)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5944,7 +5944,7 @@ static bool needsInitialization(const Variable* var)
return true;
if (var->valueType()->type == ValueType::Type::ITERATOR)
return true;
if (var->isStlType() && var->isArray()) {
if (var->isStlType() && var->getTypeName() == "std::array") {
if (const Token* ctt = var->valueType()->containerTypeToken) {
if (ctt->isStandardType())
return true;
Expand Down
6 changes: 6 additions & 0 deletions test/testuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6840,6 +6840,12 @@ class TestUninitVar : public TestFixture {
" return a[0];\n"
"}\n");
ASSERT_EQUALS("", errout_str());

valueFlowUninit("std::vector<int> f() {\n" // #15077
" const std::vector<int> a[1];\n"
" return a[0];\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
Expand Down
Loading