News for hackers. Stuff that matters.
Re:A bug in GCC that may cause memory leaks in valid C++ pro... by vvanders on Thursday April 27, 2017 @07:52PM (#14215835)
Don't you need RTTI as well? That's not been zero-cost on all compilers I've used in the past.
Re:A bug in GCC that may cause memory leaks in valid C++ pro... by int_19h on Friday April 28, 2017 @12:57AM (#14216953)
You do, but C++ includes RTTI separately from exceptions (dynamic_cast and typeid), so it's going to be there regardless. If you turn it off, then we're not talking about standard C++ anymore, but some subset.
Re:A bug in GCC that may cause memory leaks in valid C++ pro... by wvenable on Friday April 28, 2017 @01:33AM (#14217062)
When you throw and exception, C++ compilers add RTTI for those classes even when RTTI is separately disabled. You cannot call dynamic_cast and type_id but the generated code is the same.

I don't really see this as much of an issue given you have to have this RTTI to catch the exception properly.

Re:A bug in GCC that may cause memory leaks in valid C++ pro... by int_19h on Friday April 28, 2017 @03:42AM (#14217604)
My point is that RTTI is required by other things in the C++ standard, not just exceptions. So it's still "free" if we're only considering exceptions separately by themselves, and leave all other features as they are in standard C++ (and if you disable RTTI entirely, then you no longer have standard C++, since those other features also stop working).

If we consider the combo of exceptions+RTTI, then yes, dropping both at the same time lets you get rid of some further overhead (although again it's memory-only, not compute cycles). But then we have to discuss the lost benefits of those other features, not just exceptions alone, to judge whether doing so is worthwhile or not.

BTW, I may well be wrong here, but isn't RTTI generation for exceptions (when it's otherwise disabled) an example of "only pay for what you use"? i.e. wouldn't the compiler then only generate RTTI entries for those types that are either thrown somewhere, or are caught somewhere? If so, any library code that doesn't throw itself, and only needs to allow exceptions to pass through it, is still zero-overhead in that regard.