Issue |
117230
|
Summary |
clang-analyzer-alpha.cplusplus.DeleteWithNonVirtualDtor does not handle indirection through base pointer
|
Labels |
new issue
|
Assignees |
|
Reporter |
tiagomacarios
|
The following code will trigger clang-analyzer-alpha.cplusplus.DeleteWithNonVirtualDtor
https://godbolt.org/z/7jPa8dr5W
```
#include <cstdio>
struct A {};
struct B : A {
virtual ~B() { std::puts("B dtor"); }
};
struct C : B {
~C() { std::puts("C dtor"); }
};
int main() {
C* c1 = new C{};
C* c2 = nullptr;
A** pp = (A**)&c2; // note: Casting from 'C' to 'A' here
*pp = c1;
delete c2; // warning: Destruction of a polymorphic object with no virtual destructor [clang-analyzer-alpha.cplusplus.DeleteWithNonVirtualDtor]
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs