On 24/05/2017 20:54, Emil Dotchevski via Boost wrote:
I don't dispute that exception handling has overhead and that you can construct a toy example that shows that. However, people who choose to avoid exceptions make a bigger claim, something along the lines of "in my domain we can't afford exception handling overhead". I have _never_ seen hard data to support this.
I have seen two use cases to avoid exceptions: 1) Any hard error won't be handled, because it's highly unlikely, and we don't want to use more space or CPU (depending on the implementation) in something that is very unlikely. For hard errors std::terminate or a log-and-die solution is a perfectly valid option for an application (e.g. when memory is exhausted or a logic error is detected). This could be the case for some games. 2) Hidden control paths are unacceptable. Typically safety or security critical systems where every single path or branch must be tested. Explicitly error handling shows every path and code review and coverage tools are very helpful. Writing exception safe code is error-prone, specially when operations that can throw can change implicitly when inner operations of a statement start throwing new classes. The exception type thrown by is not enforced by the compiler whereas the return type is fixed at compile time. Sometimes this makes error handling much easier. Best, Ion