Question w.r.t. `'class Foo' has virtual functions but non-virtualdestructor` warning.
Gabriel Dos Reis
gdr@integrable-solutions.net
Mon Mar 7 06:08:00 GMT 2005
David Carlton <david.carlton@sun.com> writes:
| On Fri, 04 Mar 2005 19:15:41 -0600 (CST), Chris Lattner <sabre@nondot.org> said:
|
| > It's not a matter of warning vs not warning: it's a matter of
| > emitting bogus warnings *sometimes* when you can emit the proper
| > warning *all of the time*.
|
| I don't think you can emit the proper warning all of the time on
| destruction, either:
|
| void deleteB( B *obj ) {
| delete obj;
| }
|
| If B is a base class with a non-virtual destructor, then this is safe
| if obj's dynamic type is B, unsafe otherwise.
That is correct; but the number of false positive is reduced --
significantly in case where those classes appear in header files.
-- Gaby
More information about the Gcc
mailing list