blob: b2f86c4429cc5101b8ed4c0b62686671d22e9243 [file] [log] [blame]
.. title:: clang-tidy - readability-redundant-member-init
Finds member initializations that are unnecessary because the same default
constructor would be called if they were not present.
.. code-block:: c++
// Explicitly initializing the member s is unnecessary.
class Foo {
Foo() : s() {}
std::string s;
.. option:: IgnoreBaseInCopyConstructors
Default is `false`.
When `true`, the check will ignore unnecessary base class initializations
within copy constructors, since some compilers issue warnings/errors when
base classes are not explicitly initialized in copy constructors. For example,
``gcc`` with ``-Wextra`` or ``-Werror=extra`` issues warning or error
``base class 'Bar' should be explicitly initialized in the copy constructor``
if ``Bar()`` were removed in the following example:
.. code-block:: c++
// Explicitly initializing member s and base class Bar is unnecessary.
struct Foo : public Bar {
// Remove s() below. If IgnoreBaseInCopyConstructors!=0, keep Bar().
Foo(const Foo& foo) : Bar(), s() {}
std::string s;