Adding in-class `{}` default member initializers to data members of ITK classes

Generally speaking, it appears hard to avoid undefined behavior when data members of classes aren’t consistently being initialized. We saw a few cases recently:

Hereby I’m proposing to consistently use in-class default member initializers for data members of ITK classes “by default”, and only leave data members uninitialized in very specific cases (specific cases, typically where the run-time performance cost of initialization would be too high).

For those data members that did not yet have an in-class default member initializer, the following PR proposes to add a {} initializer:

The PR is limited to classes whose instances are created by New(), assuming that for those classes, the cost of the added {} initialization is neglectable compared to the cost of object creation. Please have a look: STYLE: Add in-class `{}` member initializers to objects created by New() by N-Dekker · Pull Request #3851 · InsightSoftwareConsortium/ITK · GitHub

1 Like