[LLVMdev] dyn_cast vs. dynamic_cast

Chris Lattner clattner at apple.com
Mon Nov 15 13:55:42 PST 2010


On Nov 15, 2010, at 1:38 PM, Trevor Harmon wrote:

> On Nov 12, 2010, at 5:57 PM, Óscar Fuentes wrote:
> 
>>> Could someone
>>> please explain why I should use dyn_cast instead of dynamic_cast? (I
>>> thought all classes have v-tables...) Thanks,
>> 
>> For reducing executable size, LLVM builds with RTTI disabled where
>> possible.
> 
> Right, but how does that relate to dyn_cast? I thought v-tables were  
> present even when RTTI is not (because otherwise polymorphism would be  
> impossible).

dynamic_cast uses rtti, not vtables.  dyn_cast doesn't use either, unless you implement the classof method to use it (which is not typical).

-Chris



More information about the llvm-dev mailing list