|
Boost : |
Subject: Re: [boost] D-style scope guards?
From: Eric Niebler (eric_at_[hidden])
Date: 2011-03-06 06:10:26
On 3/6/2011 9:42 AM, Jeffrey Lee Hellrung, Jr. wrote:
> On 3/5/2011 4:24 PM, Lorenzo Caminiti wrote:
>>
>> This will *not* print "returning" because the throw terminates `f()`
>> *without* executing local variables' destructors (which execute the
>> scope exit code).
> [...]
>
> Wait...I thought that was the point of Boost.ScopeExit? Aren't the
> destructors of local variables always invoked during stack unwinding?
Not if main exits via an uncaught exception. Then all bets are off.
Lorenzo is misinformed about the behaviors of ScopeExit and of C++.
-- Eric Niebler 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