This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A simple question about virtual destructors.


2016-06-02 11:55 GMT+02:00 K <kyb22@rol.ru>:
> Hi,
>
> My question is what if a compiler will generate a virtual destructor (or
> convert  a nonvirtual to virtual) in a base class if the base class has at
> least one virtual function and  classes down in the hierarchy have
> nontrivial destructors? In other words make a compiler responsible for
> proper destruction of a polymorphic object.
>
> Are there any serious pros  against this?

One thing that immediately comes to mind is the compiler would need to
know about those derived classes and their destructors when compiling
the base class.

>This suggestion can look stupid
> but just think how many type strokes and hours in searching of memory leaks
> this could save.

-Wnon-virtual-dtor or -Weffc++ could be of some help there.

>
> Kirill.
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]