[cxx-abi-dev] trivial __dynamic_cast fails?

David Abrahams dave at boost-consulting.com
Fri Feb 27 22:45:27 UTC 2004


Daveed Vandevoorde <daveed at edg.com> writes:

> On Feb 27, 2004, at 12:36 PM, Mark Mitchell wrote:
>
>> David Baraff wrote:
>>
>>> I'm playing around with the __cxxabiv1::__dynamic_cast() function.  It
>>> works as I would expect, with one exception.
>>
>> The ABI document does not require that __dynamic_cast perform a
>> derived-to-base cast.  Those __dynamic_cast operations that can
>> actually be performed statically by the compiler must be performed
>> statically by the compiler -- the runtime library does not expect to
>> be called in that situation.
>
> Indeed.  However, it is not the first time I
> encounter the desire to be able to do this
> sort of thing.  

Yeah, I've been wishing for it for at least a year.  I had no idea
that there was a function lying around (even a platform-specific one)
that actually worked that way!  My application contains a big, nasty,
portable simulation of the same functionality.

> Since the ABI specs do not
> currently say what __dynamic_cast should do
> in the cases that the compiler handles alone,
> I don't think there would be a significant
> backward compatibility issue in trying to
> support a useful design technique.  

Yes, I want the "cast up the hierarchy" capability also.

> If it
> can be done within the framework of the
> existing RTTI structures, I think it would
> be worth "upgrading" __dynamic_cast to
> address this.
>
> There has been occasional talk among WG21/
> J16 actives about adding a facility like
> what David B. is looking for, but so far
> no concrete proposals.  I'm going to CC
> David Abrahams who mentioned the desire
> for this once.  Perhaps he has some insight
> into how widespread the need for this is.

I think it's probably more widely neededthan you'd guess, at the
boundary between statically and dynamically-typed systems.  I doubt
anyone else has had the insanity to try to simulate it in conforming
code, or the wherewithal to express to implementors what they were
trying to achieve, so most people who might've needed it probably just
gave up.  That's a long-winded way of saying this is the first time
I've ever heard that someone else besides me wanted it.  If it's
(almost) in cxx abi v1, and David B. wants it, and I want it, it seems
like a few people at least have decided it's important.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the cxx-abi-dev mailing list