On 12 December 2014 at 23:38, Kendrick Hamilton <hamil...@sedsystems.ca> wrote: > Hello, > > I had an idea of a warning g++ might be able to add. The purpose of the > warning is to help prevent bugs. The warning is to occur when you might > destroy an inherited class using the base classes pointer. To illustrate > consider > > class base > { > public: > base(); > ~base(); > }; > > class inherit : public base > { > public: > inherit(); > ~inherit(); > } > > Note that the base class's destructor is not virtual.
GCC already has -Wnon-virtual-dtor and -Wdelete-non-virtual-dtor warnings. They don't warn for your example because you have no virtual functions. It's assumed that if you don't have a polymorphic type then there is no point in accessing it through a pointer to base.