help-gplusplus
[Top][All Lists]
Advanced

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

Re: dynamic_cast from base to another parent of derived class


From: Fred Zwarts
Subject: Re: dynamic_cast from base to another parent of derived class
Date: Mon, 9 Oct 2006 09:06:13 +0200

"Boris" <boris@gtemail.net> wrote in message 
4ok0g7Fep8f0U1@individual.net">news:4ok0g7Fep8f0U1@individual.net...
> Fred Zwarts wrote:
>> [...]
>> Interesting. A few years ago I had a similar problem on an OpenVMS
>> system.
>> The dynamic_cast did not work properly in a function that was called
>> from
>> another function in a shareable image (which is similar to a dynamic
>> library
>> under Linux). An example was code running in a separate thread. Since
>> the
>> pthread library was in a shareable image, functions running in
>> another thread
>> were called from functions in a shareable image.
>> The OpenVMS engineers brought out a patch for the compiler and the
>> run-time
>> library quickly.
>>
>> The similarity of these problems strikes me, as the compiler
>> environments are
>> from very different teams. Apparently there is something in
>> dynamic_cast
>> that makes it difficult to work from pre-linked parts of a program.
> 
> Could you easily reproduce the problem with a small test program or was it 
> something where some other conditions had to be met? And did you ever try to 
> link everything statically just to see if the problem disappeared?

It could not be reproduced in a small program, because it only occurred in
functions called from the shareable image. So, the test program needed
to use some library functions which in turn called the function in which 
dynamic_cast was used, which is not easy to do in a small test program.
I encountered the bug when using the pthreads library, exactly a case where
functions in a program (the start functions of the threads) are called from the 
library.
At the time I encountered the bug, it was already known to the OpenVMS 
compiler group, so I did not have to prove it with a small program, but they
recognized the case and sent me the patch.
So, the conditions under which the bug was exposed were not determined by me,
but I read them in the patch description. It gave an excellent explanation why
dynamic_cast worked in some cases, but failed in others.

Fred.Zwarts.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]