Exception specifications on functions useless?

Stephan Bergmann sbergman at redhat.com
Wed Mar 21 03:54:09 PDT 2012

On 03/21/2012 11:23 AM, Bjoern Michaelsen wrote:
> 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".

Couldn't agree less.  ;)

That C++ can throw arbitrary types, not restricted to some exception 
class hierarchy is rather orthogonal to the issues discussed so far in 
this thread.  It does *not* add "another _untyped_ return path," at 
least not any more so than it would do if throwable types in C++ were 
restricted to some specific subset.

And "avoid using C++ exceptions" is throwing out the baby with the 
bath-water.  They are not ideal, but neither are the alternatives.


More information about the LibreOffice mailing list