Search code examples
c++initializationstatic-analysis

How is `auto *x = new some_struct{};` an uninitialized variable?


Recently, I decided to try out CodeInspector.

In my code, I've written the following:

auto *v4Addr = new sockaddr_in{};

Code Inspector has flagged this line (as well as a few other similar lines) as Violation | Critical/security | Uninitialized variable: v4Addr

It is my understanding that new some_struct{} initializes the struct with 0s. Is there something I'm missing? Should I be using new some_struct() or something else instead?


Solution

  • It isn't.

    CodeInspector is wrong.

    You should report a bug to its authors.