On 06/27/2012 08:35 AM, Chiheng Xu wrote:
dynamic_cast use RTTI, while TREE_CODE are poor man's type info. RTTI
is better than TREE_CODE. But, If you decide to use RTTI,  TREE_CODE
become redundant, that means all use of TREE_CODE should be removed,
sooner or later. Are you prepared for that ?

I wasn't suggesting we would change trees to use inheritance in the forseeable future; my point was that RTTI is used in patterns like what we already do with trees, so I don't think that using it indicates a design problem.

If we were to change trees to use inheritance and virtual functions, which seems unlikely to me, then I think it would make sense to use RTTI instead of TREE_CODE.

On 06/27/2012 09:02 AM, Richard Guenther wrote:
RTTI requires more space than TREE_CODE, so it's not universally better.

RTTI requires no additional space in each object, and no space at all for classes with no virtual functions.

To answer, no - we should not enable RTTI (nor exceptions).

The problem with exceptions is that the compiler is not exception-safe. I don't think there's a good reason to prohibit RTTI. As I said in another message, I don't mind turning it off for now, but I don't think doing so has much benefit either, since it only affects classes with virtual functions.

Jason

Reply via email to