Issue |
136377
|
Summary |
[clang-tidy] bugprone-crtp-constructor-accessibility for deleted constructor
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
DimitrijeDobrota
|
In this basic example of CRTP pattern:
```c++
template<typename D>
class base
{
friend D;
base() = default;
base(const base&) = default;
base(base&&) = delete;
};
class derived : public base<derived>
{
};
```
I get the following warning, which is expected and reasonable:
```
project_root/test.cpp:9:3: warning: deleted member function should be public [hicpp-use-equals-delete,modernize-use-equals-delete]
9 | base(base&&) = delete;
| ^
```
while on the other hand, if I were to move the constructor to the public area:
```c++
template<typename D>
class base
{
friend D;
base() = default;
base(const base&) = default;
public:
base(base&&) = delete;
};
class derived : public base<derived>
{
};
```
the following warning is not needed since the constructor has been deleted:
```
project_root/testcpp:10:3: warning: public contructor allows the CRTP to be constructed as a regular template class; consider making it private [bugprone-crtp-constructor-accessibility]
10 | base(base&&) = delete;
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs