https://clang.llvm.org/extra/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.html
- The first example doesn't compile (
virtual void ~Base();)
- The example also produces a clang-analyzer-cplusplus.NewDelete warning, which might lead to confusion
A better example could be
struct Base {
virtual ~Base();
int i;
};
struct Derived : public Base {};
int foo(const Derived d[]) {
return d[1].i;
}
In this case, making Derived final suppresses the warning, which should also be mentioned.