Draft: Fix cppcheck warnings
Summary
This MR is a collection of some commits to fix warning given by the cppcheck static code analyzer tool. It can be summarized into four types of coding rules:
- All members in a class should be properly initialized
- Single-argument constructors should be marked
explicit
- Assert statements should not trigger side-effects
- Vectors and strings should be passed as
const&
unless into a sink. Then it can be moved from a copy.
Note, the rules do not apply in all cases, but mostly. The explicit
qualifier on constructors, for example, can be omitted if the implicit conversion of an argument to the class type is intended. This is not always obvious. The (MPI)Future classes, for example, seem to rely on implicit conversion. This should be made more clear by proper documentation in the code. Unfortunately, there is no "implicit" keyword in c++. With c++20 we then have a explicit(false)
qualifier to reach the same.
Note
The explicit
keyword on some constructors might have an effect on downstream code. It thus should be tested thoroughly. Probably we should deprecate the non-explicit constructors first. This might introduce a lot of extra code just for the deprecation.