Fix 10119: ValueFlow; object member is not uninitialized. happens when there is static member also. (#3299)

This commit is contained in:
Paul Fultz II 2021-06-19 06:58:18 -05:00 committed by GitHub
parent a7707a457d
commit eb7b225fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -907,7 +907,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
unknown = true;
}
}
} else if (!var->hasDefault())
} else if (!var->hasDefault() && !var->isStatic())
needInitialization = true;
}

View File

@ -4832,6 +4832,18 @@ private:
" if (!isNull) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #10119
valueFlowUninit("struct Foo {\n"
" int i{};\n"
" static const float cf;\n"
"};\n"
"const float Foo::cf = 0.1f;\n"
"int bar() {\n"
" Foo f;\n"
" return f.i;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void uninitvar_ipa() {