From -4187446425428848706
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,96a8c01f7043c2d9
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-09-03 13:42:15 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!area.cu.mi.it!news.mailgate.org!newsfeed.icl.net!newsfeed.fjserv.net!news-lond.gip.net!news.gsl.net!gip.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: terekhov@web.de (Alexander Terekhov)
Newsgroups: comp.std.c++
Subject: Re: Proposal: exception stack unwinding resumption
Date: Tue, 3 Sep 2002 20:42:14 +0000 (UTC)
Organization: Demon Internet@Thus PLC
Lines: 85
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <3D751AAD.59EBC3F1@web.de>
References: <6df0c6a8.0208260746.633710cb@posting.google.com> <zllb9.458$S51.25977@newsfep1-gui.server.ntli.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: mail2news.demon.co.uk 1031085734 3042 10.0.0.1 (3 Sep 2002 20:42:14 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 3 Sep 2002 20:42:14 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.05)
	id 17mKV3-0000mv-00
	for mail2news@news.news.demon.net; Tue, 03 Sep 2002 20:42:13 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id GAA02799; Wed, 4 Sep 2002 06:42:10 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ncar.ucar.edu
X-Newsgroups: comp.std.c++
X-Reply-To: terekhov@web.de
X-Orig-NNTP-Posting-Host: ss4.bluebird.ibm.com (129.42.208.142)
X-Orig-X-Trace: fu-berlin.de 1031084693 56813441 129.42.208.142 (16 [158401])
X-Accept-Language: en
Xref: archiver1.google.com comp.std.c++:13583


Garry Lancaster wrote:
[...]
> I don't think the proposal adds enough to what we
> already have to warrant its inclusion in the language.

What about "bool future_std::expected_exception<T>" and 
the entire "10 o'clock"-wish list:

http://groups.google.com/groups?q=insubject:overloaded+insubject:destructors+author:terekhov%40web.de&scoring=d&filter=0
(Subject: Re: A half serious proposal: overloaded destructors)

<?>

Oh, BTW, I've got one more "item"...

< Forward Inline; FYI: http://www.gotw.ca/publications/xc++-errata.htm >

-------- Original Message --------
Message-ID: <3D74BF08.AA0D377@web.de>
Date: Tue, 03 Sep 2002 15:54:16 +0200
From: Alexander Terekhov <terekhov@web.de>
Reply-To: terekhov@web.de
Newsgroups: comp.lang.c++.moderated
Subject: Re: "Exceptional C++", Item 5 (GoTW 16b, I think)


Jim Fischer wrote:
> 
> At the top of page 16 in Herb Sutter's book "Exceptional C++" he
> mentions that a fixed_vector object will be in an inconsistent state if
> one of the T assignments fails during the copy() operation. The text and
> code on pp 16-18 takes some steps to address this issue. IMO, however,
> the proposed "new-and-improved" code at the bottom of page 16 has
> introduced a new exception-safety issue. Note that the templated
> converting ctor and the copy ctor (p.16) both have the following form:
> 
> fixed_vector( const fixed_vector<T,size>& other )
> : v_( new T[size] )
> {
>     copy( other.begin(), other.end()+min(size,osize), begin() );
> }
> 
> If the copy() call fails due to an exception being thrown, these ctors
> will "leak" their dynamically allocated memory, right? 

Right, unless you prefer to use REAL objects vs "dumb" pointers; 
auto_ptr_array<T>, in this case for "v_" member. Well, another 
RAII-less-approach that wouldn't "steal" each and every exception 
(as catch(...)/rethrow without ES protection unfortunately does), 
would be to use some currently nonexistent "soft"/"cleanup"-catch 
"construct":

fixed_vector( const fixed_vector<T,size>& other )
: v_( new T[size] )
{
    try {
      copy( other.begin(), other.end()+min(size,osize), begin() );
    }
    catch(...) CLEANUP { /* THIS DOESN'T CATCH *UNEXPECTED* EXCEPTIONS */
                         /* THIS DOES RETHROW EXCEPTIONS AUTOMATICALLY */
                         /* NOTHING ELSE CAN BE THROWN FROM THIS BLOCK */
      delete[] v_;
    }
}

http://groups.google.com/groups?threadm=Aiob9.18%24c7.126076%40news.cpqcorp.net
(check out followup(s) as well; and, BTW, this 
 entire thread is about exceptions and cleanup)

regards,
alexander.

--
"~sentry();

 4 If ((os.flags() & ios base::unitbuf) && !uncaught exception()) 
   is true, calls os.flush()."   --ISO/IEC 14882:1998(E) Pg. 642

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



