Sign in to follow this  
Prune

Cost of enabling RTTI with /GR in code that doesn't use it?

Recommended Posts

In a few places I use dynamic_cast and so I had to put /GR in MSVC. What is the reason that RTTI can be disabled with /GR- in MSVC unless there is a performance penalty even in code that doesn't use RTTI functions like dynamic_cast and typeid?

Share this post


Link to post
Share on other sites
It's not really a performance penalty, it's a size penalty. If you enable RTTI extra data is generated and it makes your binary bigger. It also prevents vtable folding if for some reason any of your classes would otherwise have identical vtables. Otherwise code that doesn't use RTTI won't notice the extra information floating around.

Share this post


Link to post
Share on other sites
Compilers don't control how your cache work. That's hardware. RTTI data is laid out in a read only data segment by default. It tends to be placed next to other RTTI data and exception handling data structures. Some of the data structures for RTTI are actually shared with exception handling mechanisms for MSVC.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this