TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  ERR#006

Synopsis:Only use exception specifications when you must constrain the set of exceptions that might be thrown from a function
Language:C++
Severity Level:1
Category:Error Handling


Description:

It requires careful thought to design an exception handling strategy, including the decision which interfaces will specify exceptions that might be thrown.

Beware of the consequences when an exception specification is violated! When a function throws an exception (possibly indirectly thrown by a nested function call) that does not match its specification, then the program will be usually be aborted without proper cleanup. This is almost never desirable.

Note that, for good reasons, possible violations of exception specifications are not statically checked at compile time. For details, see ref. [Stroustrup] and [StroustrupDE].

Consider to use only empty exception specifications, in order to guarantee that a certain function will never throw an exception. The compiler might use this for performance optimization. If in any doubt, do not use exception specifications.



Literature References:
ISC++ Rec 12.16