Boost logo

Boost :

Subject: Re: [boost] [Thread] Win32 exception handling
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-25 15:26:33


on Tue Nov 25 2008, "Emil Dotchevski" <emil-AT-revergestudios.com> wrote:

> On Tue, Nov 25, 2008 at 11:59 AM, David Abrahams <dave_at_[hidden]> wrote:
>>
>> on Tue Nov 25 2008, Matt Gruenke <mgruenke-AT-intellivid.com> wrote:
>>
>>> Some compilers (certainly GCC) have the ability to preserve the
>>> stackframe from the time it was thrown (!), for uncaught exceptions.
>>> If you catch (...), then the destructors of all the locals will
>>> execute and you'll lose some information that could be instrumental in
>>> tracking down the cause of the exception.
>>
>> Right, that's essentially the MSVC/Win32 behavior I'm describing.
>>
>>> For that reason, among others, it's good to avoid the catch/rethrow construct.
>>>
>>> The catch (...) is one of the reasons we don't use boost::thread. I
>>> even filed a bug on it:
>>>
>>>
> http://sourceforge.net/tracker/index.php?func=detail&aid=1274707&group_id=7586&atid=357586>>
>>
>> OK, great, a second data point. How do you feel about the fact that the
>> upcoming standard requires the catch(...)?
>
> Maybe I'm missing something but what in the upcoming standard requires
> the catch(...)?

The requirement that terminate() be called when the exception isn't
otherwise caught. Of course you can do it with "compiler magic" because
the standard doesn't specify an implementation. Practically speaking,
though, it means a catch(...) in the library.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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