|
Boost : |
Subject: Re: [boost] [Thread] Win32 exception handling
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-25 15:41:27
on Tue Nov 25 2008, "vicente.botet" <vicente.botet-AT-wanadoo.fr> wrote:
> ----- Original Message -----
> From: "Matt Gruenke" <mgruenke_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Tuesday, November 25, 2008 8:01 PM
> Subject: Re: [boost] [Thread] Win32 exception handling
>
>
>>
>> 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.
>>
>> For that reason, among others, it's good to avoid the catch/rethrow
>> construct.
>
> Please could some one explain in which cases the destructors of all
> the locals are not executed?
When the program exits due to an uncaught exception, it is up to the
compiler vendor whether those locals will be destroyed. If you want to
portably ensure destruction, put a catch(...) in main. If you want to
portably ensure non-destruction in case of an uncaught exception, you're
out of luck. You may of course have knowledge about your particular
compiler.
> Can the stack-frame be recovered in some way just before the
> destructors are called?
That's dependent on your specific compiler implementation.
-- 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