[PATCH] dynamic_cast and gcc3

Simon Hausmann hausmann at kde.org
Tue Nov 19 14:57:57 GMT 2002


On Tue, Nov 19, 2002 at 03:45:00PM +0100, Matthias Kretz wrote:
> On Tuesday 19 November 2002 14:37, Simon Hausmann wrote:
> > On Mon, Nov 18, 2002 at 05:01:56PM +0100, Matthias Kretz wrote:
> > > I'm sorry, I missed a few dynamic_casts in the KView plugins. See #50769.
> > > This should fix all problems - dunno why I used dynamic_cast at all...
> >
> > I hope you are away of the side-effect of this change that
> > static_cast only returns a null pointer if the passed object is a
> > null pointer, not if the type mismatches, i.e. it is unsafe for type
> > inspection.
> 
> Yes, you're right I didn't think a lot about the problems this change can 
> create... Probably a qt_cast would help here.
> 
> /me is creating another patch... or not. This can't work since the 
> KImageViewer::Viewer interface is pure virtual and not a Q_OBJECT. So the 
> qt_cast will always fail.
> I could add the Q_OBJECT macro to the interface and create a lib and all that, 
> but... not before 3.1, right?

How about adding a default implementation for one of those pure
virtual methods and compile them into a shared library (isn't there
already some kview library that all plugins link against?) . I think
that should convince gcc to emit the type info as well and cause
everyone to share the same type info symbols at run-time (making the
use of d-cast safe) .

Simon




More information about the kde-core-devel mailing list