On Tue, Nov 22, 2011 at 08:29:44PM +0100, Peter Kümmel wrote: > On 21.11.2011 23:32, André Pönitz wrote: > >On Mon, Nov 21, 2011 at 10:53:49PM +0100, Peter Kümmel wrote: > >>On 21.11.2011 21:24, André Pönitz wrote: > >>> > >>>First guess: gcc sees 'virtual' on two member functions but no virtual > >>>destructor, cannot prove that delete operates only on static type == > >>> > >> > >>Yes, seems the warning is completely valid: GuiWorkArea::Private has a > >>virtual table but no virtual destructor. It points to superfluous > >>virtual functions which are wrong in GuiWorkArea::Private and only > >>slow down the code. > > > >We seem to have different opions on what constitutes a "valid" warning. > > > >I am not a native English speaker, but in my limited understanding of > >the language > > > > "GuiWorkArea.cpp:327:9: warning: deleting object of polymorphic class type > > ‘lyx::frontend::GuiWorkArea::Private’ which has non-virtual destructor > > might > > cause undefined behaviour " > > But this statement is still correct (polymorphic and non-virtual destructor), > the other was only my optinion. It is like a hint to a coding-rule.
This particular code is safe, and the compiler has all the information necessary to even prove it. It chose to complain instead. Next year we'll get compiler warnings on "i = 1;" as there's the possibility that the programmer meant to say "i = 2;" ... And I don't buy the "coding rule" reasoning as the line number given by the compiler is completely unrelated to the two lines that need to be changed to solve the "issue" properly. A naive follow-up on the compiler's advice would have been to make the destructor virtual, which would have "wasted" a dozen more cyles. Andre"