Exception specifications on functions useless?

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed Mar 21 03:23:39 PDT 2012


Hi all,

On Tue, Mar 20, 2012 at 10:50:02PM +0100, Lubos Lunak wrote:
> - boost, and pretty much everybody else it seems, do not consider it worth the 
> hassle of specifying what a function may or may not throw, except for 
> flagging a non-inline method as not throwing any exception at all as a means 
> of optimization for places where such functions are called

For the most part I would agree here. C++ exceptions are broken by design.
Allowing any kind of object (not even exception) to be thrown by default in a
function adds another _untyped_ return path (as if every function would return
a void* in addition to its return code). Which is exactly what you do _not_
want in a strongly typed environment. Since we are using bazillions of external
libraries, we have no way to fix this even if we would try to.

IMHO exceptions in C++ are a failed implementation, and if there is any general
advise about them, it is: "Avoid using C++ exceptions".

Best,

Bjoern

P.S.: see also http://yosefk.com/c++fqa/exceptions.html





More information about the LibreOffice mailing list