| Issue |
183496
|
| Summary |
[clang-tidy][check request] Detect implicit conversion from `unique_ptr<Derived>` to `unique_ptr<BaseWithNonVirtualDtor>`
|
| Labels |
clang-tidy,
check-request
|
| Assignees |
|
| Reporter |
zwuis
|
From [std::unique_ptr - cppreference.com](https://en.cppreference.com/w/cpp/memory/unique_ptr.html#Notes):
> If `T` is a [derived class](https://en.cppreference.com/w/cpp/language/derived_class.html) of some base `B`, then `unique_ptr<T>` is [implicitly convertible](https://en.cppreference.com/w/cpp/memory/unique_ptr/unique_ptr.html) to `unique_ptr<B>`. The default deleter of the resulting `unique_ptr<B>` will use [`operator delete`](https://en.cppreference.com/w/cpp/memory/new/operator_delete.html) for `B`, leading to [undefined behavior](https://en.cppreference.com/w/cpp/language/destructor.html#Virtual_destructors) unless the destructor of `B` is [virtual](https://en.cppreference.com/w/cpp/language/virtual.html). ...
If the second template argument of `unique_ptr` is not same as corresponding default argument, it should be excluded from this check.
Inspired from https://github.com/llvm/llvm-project/pull/164212#discussion_r2649055764 and #183101.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs