diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 4d01d35b1..331a81322 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -929,7 +929,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization() if (var.isClass()) { if (var.type()) { // does this type need initialization? - if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault()) + if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault() && !var.isStatic()) needInitialization = true; else if (var.type()->needInitialization == Type::NeedInitialization::Unknown) { if (!(var.valueType() && var.valueType()->type == ValueType::CONTAINER)) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 497a23ebe..50fd36bf7 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -6249,6 +6249,18 @@ private: " S s2 = s1;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #11460 + valueFlowUninit("struct B { int i; };\n" + " struct H {\n" + " void e() const;\n" + " static const B b;\n" + "};\n" + "void f() {\n" + " H h;\n" + " h.e();\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void uninitvar_memberfunction() {