• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. title:: clang-tidy - bugprone-copy-constructor-init
2
3bugprone-copy-constructor-init
4==============================
5
6Finds copy constructors where the constructor doesn't call
7the copy constructor of the base class.
8
9.. code-block:: c++
10
11    class Copyable {
12    public:
13      Copyable() = default;
14      Copyable(const Copyable &) = default;
15    };
16    class X2 : public Copyable {
17      X2(const X2 &other) {} // Copyable(other) is missing
18    };
19
20Also finds copy constructors where the constructor of
21the base class don't have parameter.
22
23.. code-block:: c++
24
25    class X4 : public Copyable {
26      X4(const X4 &other) : Copyable() {} // other is missing
27    };
28
29The check also suggests a fix-its in some cases.
30