<div dir="ltr"><div>Hi all!</div><div><br></div><div>I just finished writing a clang-tidy check to flag uninitialized members variables. I was thus very happy to see the cppcoreguidelines-pro-type-member-init check land in clang-tidy mainline recently! The documentation for this clang-tidy check implies it's targeting "Type.6: Always initialize a member variable." It seems like some aspects might be missing, though, and I was wondering if there's anyone working on adding them or if the plan is to keep the current check as is.</div><div><br></div><div>Type.6's enforcement section reads:</div><div>• Issue a diagnostic for any constructor of a non-trivially-constructible type that does not initialize all member variables. To fix: Write a data member initializer, or mention it in the member initializer list.</div><div>• Issue a diagnostic when constructing an object of a trivially constructible type without () or {} to initialize its members. To fix: Add () or {}.</div><div><br></div><div>Right now, the clang-tidy check only seems to address the first bullet point yet only partially. It flags member variables that are built-ins or pointers. Based on my reading, it needs to flag any trivially constructible typed members, not just built-ins and pointers, excepting fully in-class initialized record types. If the second bullet point were addressed, either in this check or a separate one, the two together should cover the full text.</div><div><br></div><div>The other thing I wonder about is whether trivially constructible is too narrow. There are types that are not trivially constructible, at least in the definition that I know, that still should be flagged:</div><div><br></div><div>struct Foo {</div><div>  int Bar;</div><div>  std::string Baz;</div><div>};</div><div><br></div><div>Foo is not trivially constructible because Baz has a user defined constructor, yet a default initialized Foo will leave Bar in an indeterminate state. Therefore, it seems like we need to initialize any member that is one of the following:</div><div>A. Built-in or pointer type</div><div>B. Record type without a user-provided default constructor with at least one member that needs to be initialized as per these criteria</div><div>C. Array of any type matching these criteria*</div><div><br></div><div>Is anyone actively working on these aspects of Type.6 or is that something that I should look into?</div><div><br></div><div>* One might prefer arrays to be default initialized for performance reasons in some cases. Perhaps this should be an option.</div><div><br></div><div>Thanks!</div><div>Michael Miller</div></div>