[Interest] dynamic_cast failing

René J.V. Bertin rjvbertin at gmail.com
Sun Apr 12 15:05:56 CEST 2015


On Sunday April 12 2015 12:02:03 Nikos Chantziaras wrote:

>When you get into undefined behavior, then you can't assume that 
>something will fail. It might work or it might not. Thiago's suggestions 
>are worth investigating (executable formats on different platforms might 
>be handling inline virtuals differently, for example, causing this to 
>work here but not there.)

Which I did, first the one non-virtual dtor in the class inheriting the 4 others (and being cast *from*). And then the visibility of the target class, where I hit jackpot.

>Your problem might not have anything to do with it. But it just happens 
>that many people use multiple inheritance while not being fully aware of 
>the intricate details of doing so. You always hear people suggesting 
>that you should avoid multiple inheritance because it's very easy to 
>shoot yourself in the foot with it.

I tend to agree (and make it such a habit that I wouldn't even be able to affirm without looking it up if ObjC supports the feature).

But this is also a good example how cross-platform development can help you trace conceptual bugs. There's another one of those in Okular: using a plugin as a link-time library. That works on Linux, but with the most appropriate way of building plugins on OS X it doesn't (nor is it possible on MS Windows, AFAIK).

R.



More information about the Interest mailing list