Article View: comp.std.c++
Article #2477Re: Exceptions in destructors.
From: John Max Skaller
Date: Thu, 09 Nov 1995 10:13
Date: Thu, 09 Nov 1995 10:13
59 lines
2111 bytes
2111 bytes
James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> wrote:
>
>
>While trying to implement an exception-safe array class (and model it
>on the built-in C style arrays as closely as possible), it occured to
>me that the draft doesn't really have much to say about the case of
>exceptions thrown in destructors. Two cases occur to me:
>
>1. Given:
>
> T a[ 5 ] ;
>
>When destructing the third element (for example), an exception is
>thrown. Are the remaining elements destructed? I would say yes.
I agree. "Stack unwinding" and "object unwinding"
(destruction) are closely related. If during destruction
an exception is thrown, destruction continues (provided
there is a reachable handler)
>does the memory get freed
>(operator delete[] get called)?
>I can find nothing in the draft
>standard to indicate that it does, but if it doesn't, how does one go
>about freeing it later?
Good point. That kind of makes it necessary that
a scheduled dealloctation occur, despite any exception
thrown. As if:
delete p;
meant:
try { p->~P(); }
catch(...) {
operator delete(p);
throw;
}
operator delete(p);
[Smly for array case?]
--
John Max Skaller voice: 61-2-566-2189
81 Glebe Point Rd fax: 61-2-660-0850
GLEBE NSW 2037 email: maxtal@suphys.physics.oz.au
AUSTRALIA email: skaller@maxtal.com.au
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<47s22g$gb1@oznet03.ozemail.com.au>Path:
arc1-ca.pugleaf.net!news.mindlink.net!agate!agate!MattReferences:
<9511061549.AA15364@lts.sel.alcatel.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.mindlink.net!agate!agate!Matt From: John Max Skaller <maxtal@suphys.physics.su.oz.au> Newsgroups: comp.std.c++ Subject: Re: Exceptions in destructors. Date: 09 Nov 1995 10:13:44 GMT Organization: MAXTAL Approved: Matt@Austern Message-ID: <47s22g$gb1@oznet03.ozemail.com.au> References: <9511061549.AA15364@lts.sel.alcatel.de> NNTP-Posting-Host: austern.hip.berkeley.edu