This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Turning off C++ casting?
- From: Paolo Bonzini <paolo dot bonzini at polimi dot it>
- To: gcc at gcc dot gnu dot org
- Cc: mongryong at sympatico dot ca
- Date: Thu, 20 Feb 2003 09:57:32 +0100
- Subject: Re: Turning off C++ casting?
- Reply-to: bonzini at gnu dot org
> But if I'm iterating over lots of
> objects, I'd like to get rid off the cost of dynamic_cast when I know
> for sure the objects will always be of this type.
assert and the pointer version of dynamic_cast are your friends if you don't
want #ifdefs.
assert (dynamic_cast<ExtendedObject*>(&baseObj) != NULL);
ExtendedObject& obj = *reinterpret_cast<ExtendedObject*>(&baseObj);
> What I want to know is whether GCC allows you to optimize
> 'dynamic_cast'ing: gcc -fno_dynamic_cast .... I don't think gcc has
> such a switch.
Maybe -fno-rtti (along with disabling much more)?
Paolo