Open llvmbot opened 2 years ago
I think I just hit the same issue with a simpler repro.
Initializing S with {} triggers the false positive. () works fine.
https://godbolt.org/z/3rTdacqo7
struct S {
int i1 = 0;
};
struct K : S {
int ii1 = 0;
K() : S() {}
// K() : S{} {}
};
void _() {
K k;
}
Extended Description
Checker UninitializedObject is enable by default in clang-tidy and reports some false positives. Tests case(UninitializedObjectChecker_false_positive.cpp) :
struct Operand_ { int e; int a[2]; };
class b : Operand { public: b() : Operand{ 1, { 2, 3 }} {} };
void c() { b(); }
It returns wrong warning:
UninitializedObjectChecker_falsepositive.cpp:9:17: warning: 1 uninitialized field at the end of the constructor call [optin.cplusplus.UninitializedObject] b() : Operand{ 1, { 2, 3 }} {} ^
~~~~~ UninitializedObjectChecker_falsepositive.cpp:3:7: note: uninitialized field 'this->Operand::e' int e; ^ 1 warning generated.Arguments for clang-12 or clangs-13 in trunk:
clang-12 -c UninitializedObjectChecker_false_positive.cpp -Xclang -analyzer-checker=optin.cplusplus.UninitializedObject -Xclang -analyze