[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: hidden virtual functions
From:       Stephan Kulow <coolo () kde ! org>
Date:       2000-07-05 9:01:00
[Download RAW message or body]

Dirk Mueller wrote:
> 
> On Die, 04 Jul 2000, David Faure wrote:
> 
> > The problem is that _those_ are not wrong, but -Woverloaded-virtual is a very useful
> > flag to find the cases where a derived class is supposed to reimplement
> > a method but doesn't because of a mistake in the signature.
> 
> Well, I doubt it's useful.
> 
> example kdelibs/kdecore/kdestyle.h:
> 
> qt/include/qstyle.h:69: warning: `QStyle::polish(QApplication *)' was hidden
> kdestyle.h:68: warning:   by `KDEStyle::polish(QPalette &)'
> 
> Well, there is a virtual method with the signature polish(QPalette&) as
> well, and that's exactly the signature that should get overwritten. Can you
> tell me why it warns about the signature with QApplication* here?
> 
> Furthermore coolo "fixed" this by adding a "dummy" virtual method. Except
> that this has no real usage, it also introduces bugs: the overwritten method
> now does nothing, instead of possibly *something* before. And those dummy
> methods are binary incompatible and just a waste of memory and CPU
> time. Pretty expensive fix for a useless compiler warning IMHO.
How? They are exactly the same as the ones in their base class. And a
call
to them did a vtbl lookup before too. You're right that the functions I
added
may be a bit too dummy, but I'm not sure what they should do otherwise.
Most
aren't used or called by someone else. If you look the QStyle::polish
function
is dummy too. 

> 
> I can't see why it is good at this stage to introduce another set of
> possibly very, very hard to find bugs into the source.
> 
I found at least 3 bugs using this option, where people forgot a const
in the signature and the virtual function wasn't what they thought it
would
be. 
The dummy functions do not harm anyone, they just make the compile clear
that the situation was intended. The only remaining question is what the
dummy implementations should do.

Greetings, Stephan

-- 
... but you ain't had mine

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic