Boost logo

Boost :

Subject: Re: [boost] [contract] invariant checking after destructor throw
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2012-09-03 17:36:23


2012/9/3 Dave Abrahams <dave_at_[hidden]>

>
> on Tue Aug 28 2012, Andrzej Krzemienski <akrzemi1-AT-gmail.com> wrote:
>
> > 1. According to the standard, an object is considered destroyed (its
> > life-time has ended) when its destructor *starts*. Even if it throws an
> > exception, it is considered destroyed, so accessing its members (in order
> > to check for the invariant) may be illegal (an undefined behavior).
>
> It's not undefined behavior. The members and bases are not yet
> destroyed. Otherwise, how would you release any resources held in
> mmebers?
>

Perhaps I am being imprecise. What I mean is that at the time the invariant
would be executed, the exception would have "left" the destructor of the
derived class, so members and bases would have been destroyed.

Regards,
&rzej


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