David Faure wrote:

> On Monday 05 December 2005 14:50, Tommi M?kitalo wrote:
>> Exceptionhandling makes errorhandling easy and safe especially in deep
>> call stacks (more than 1;-) ).

>
> Except when a destructor involved in the stack-unwinding makes a call
> which itself raises an exception ... and then ... kaboom. Not allowed by
> the standard. abort(). With a rather confusing backtrace. Fun, isn't it?


Yes. That's why many C++ books strongly suggest that destructors never
throw, either by:

- calling only nothrow function from destructors
- adding try/catch block inside destructor

This is not very different from error codes. If you have

return SOME_ERROR;

and destructor of some automatic variable calls a function that fails, what
do you? You can't return error code, because destructors have no return
value, and you already have return value anyway. So, you can only check
the return value in destructor and do some other kind of error reporting.
Destructors are already special, exceptions don't much to that. Well, except
that with error codes it's easier to ignore all errors in destructor ;-)

- Volodya





>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<