My company uses Parasoft to validate the correctness of our c/c++ program.
In the source code, many classes are not used as base class and they don't have virtual member functions. But they inherit from other class. Here is the sample code:
class class_a : public base{
protected:
int* pa;
public:
class_a();
~class_a(){free(pa);};
int* get_a(){return pa};
...
}
However, parosoft says:
Destructor ~class_a should be virtual
If I change the destructor to be virtual, the violation disappears.But I don't think this is the correct way to fix it.
So, Is this just false violation message or are there actually some flaws in our code?
What may cause this kind of parasoft error?
Under what conditions will parasoft show the same error message?
Follow up: Many of these classes define functions that are totally the same with their base class.These functions are non-virtual.