What's the advantages of turning off RTTI from compiler setting?
By this(How expensive is RTTI?), it seems clear that dynamic casting is much expensive than static type comparison, but I wonder if it would be worth to turn off RTTI option in compiler option(VS2010, /GR-)
I have no dynamic cast in my code(I replaced them with static cast). But does (/GR-) option do any other than emitting errors when using dynamic cast? Is there any memory or code optimization in there?
Thanks in advance.
Straight from MSDN (emphasis mine):
When /GR is on, the compiler defines the _CPPRTTI preprocessor macro. By default, /GR is on. /GR- disables run-time type information.
Use /GR if the compiler cannot statically resolve an object type in your code. You usually need the /GR option when your code uses dynamic_cast Operator or typeid. However, /GR increases the size of the .rdata sections of your image. If your code does not use dynamic_cast or typeid, /GR- may produce a smaller image.
Looks like turning RTTI off is worth it in your case.
There may be some memory decrease (since the data required for RTTI are not needed), but in most practical cases you will find it completely negligible, so in most practical cases it is not worth it.