Boost logo

Boost :

Subject: Re: [boost] [exception] current_exception mishandlingstandardexceptions
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-05-14 17:59:14


On Thu, May 14, 2009 at 1:16 PM, Adam Badura <abadura_at_[hidden]> wrote:
>   Still there are reasons. In cases someone wants extra care he/she cannot
> use Boost.Exception data injection because this always adds risk of double
> failure - lack of memory and std::bad_alloc

This isn't double failure -- your program correctly attempts to do
something (throw an exception, in this case) and fails, which results
in bad_alloc exception. There is no difference between this situation
and a bad_alloc you could get if you attempt to copy a string (for
example.)

Also, some compilers allocate exceptions on the heap. I don't see 15.1
specifying behavior in case this allocation fails, so clearly an
attempt to throw an exception may fail. In this case, whether you get
a std::bad_alloc or abort() won't make much difference, either way
your program isn't going to throw the exception you wanted to throw
(any expert care to comment on this issue?)

>   So to sum up IMHO if the implementation already uses this mechanism and
> all the required work is to make it public and document it then I would do
> it even if I didn't see practical use at the moment

Maybe I wasn't clear: I am not against making this change in Boost
Exception, I am against doing it without understanding the use cases
that require the change.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk