[clang] [analyzer] Fix uninitialized base class with initializer list when ctor is not declared in the base class (#70464) (PR #70792)

Ella Ma via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 08:06:13 PDT 2023


Snape3058 wrote:

As #59493 is an array, which is different from the test case I provided and the ones in #61919 and #54533,
although this pr can correctly handle the array case, do I still need to add the array one to the test case?

```cpp
// Additional test case from issue #59493
namespace init_list_array {

struct Base {
  int foox[1];
};

class Derived : public Base {
public:
  Derived() : Base{{42}} {
    // The dereference to this->foox below should be initialized properly.
    clang_analyzer_dump(this->foox[0]); // expected-warning{{42 S32b}}
    clang_analyzer_dump(foox[0]); // expected-warning{{42 S32b}}
  }
};

void entry() { Derived test; }

} // namespace init_list_array 
```

https://github.com/llvm/llvm-project/pull/70792


More information about the cfe-commits mailing list