Re: [gtkmm] GCC 3.3.1 breaks gtkmm



On Thu, Jul 17, 2003 at 08:30:13PM +0100, Chris Vine wrote:
> I do not think this is right.  I think you are confusing virtual inheritance 
> where multiple inheritance is involved and polymorphism (virtual methods).  
> You can use static_cast for polymorphic classes (but the "goodness" of the 
> cast is not checked, so should only be used where you know the origin of the 
> object concerned).  dynamic_cast is required to the exclusion of static_cast 
> only where you have multiple inheritance involving a virtual base class 
> (which in addition and to add to the confusion must also have a virtual 
> method so that it has the necessary type information available, as with all 
> dynamic_casts).  Incidentally, if a dynamic_cast will work, the standard also 
> allows a C style cast to be used with multiple inheritance.

Yes, you are correct. My mistake in misinterpretation of the text.

> I agree that if it is a gtkmm bug, we should not be trying to get round it by 
> using reinterpret_cast, because whilst the result will technically be 
> compilable C++, the pointer will be unusable where casting from  a virtual 
> base clase having multiple inheritance.  And if it is a gcc bug (as I 
> strongly suspect since otherwise the gtkmm code should never have worked) we 
> should await a fix to gcc rather than using a hack like
> reinterpret_cast.

Using a dynamic_cast works on the outer cast, and isn't a hack so much
as avoiding the static_cast bug in gcc, where as you point out it
should be allowed.

Barnaby



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]