Bug hunting: Avoid uninit struct member false positives
This commit is contained in:
parent
f95a53b0ca
commit
7c8c0ef3a2
|
@ -2512,7 +2512,7 @@ static ExprEngine::ValuePtr createStructVal(const Scope *structScope, bool unini
|
|||
std::shared_ptr<ExprEngine::StructValue> structValue = std::make_shared<ExprEngine::StructValue>(data.getNewSymbolName());
|
||||
auto uninitValue = std::make_shared<ExprEngine::UninitValue>();
|
||||
for (const Variable &member : structScope->varlist) {
|
||||
if (uninitData) {
|
||||
if (uninitData && !member.isInit()) {
|
||||
if (member.isPointer()) {
|
||||
structValue->member[member.name()] = uninitValue;
|
||||
continue;
|
||||
|
|
|
@ -44,6 +44,7 @@ private:
|
|||
TEST_CASE(uninit_bailout);
|
||||
TEST_CASE(uninit_fp_smartptr);
|
||||
TEST_CASE(uninit_fp_struct);
|
||||
TEST_CASE(uninit_fp_struct_member_init_2);
|
||||
TEST_CASE(uninit_fp_template_var);
|
||||
TEST_CASE(ctu);
|
||||
#endif
|
||||
|
@ -202,6 +203,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninit_fp_struct_member_init_2() {
|
||||
check("struct A {\n"
|
||||
" int x {0}; int y {0};\n"
|
||||
"};\n"
|
||||
"void foo(const A& a) {\n"
|
||||
" bar(a);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninit_fp_template_var() {
|
||||
check("void foo() {\n"
|
||||
" X*x = DYNAMIC_CAST(X, p);\n"
|
||||
|
|
Loading…
Reference in New Issue