From 2928405624763497080
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,96a8c01f7043c2d9
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-09-03 10:49:21 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!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: pierrebai@hotmail.com (Pierre Baillargeon)
Newsgroups: comp.std.c++
Subject: Re: Proposal: exception stack unwinding resumption
Date: Tue, 3 Sep 2002 17:49:20 +0000 (UTC)
Organization: http://groups.google.com/
Lines: 54
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <6df0c6a8.0209030656.249192ce@posting.google.com>
References: <6df0c6a8.0208260746.633710cb@posting.google.com> <zllb9.458$S51.25977@newsfep1-gui.server.ntli.net>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: mail2news.demon.co.uk 1031075360 1629 10.0.0.1 (3 Sep 2002 17:49:20 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 3 Sep 2002 17:49:20 +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 17mHni-0000Q8-00
	for mail2news@news.news.demon.net; Tue, 03 Sep 2002 17:49:19 +0000
X-Received: by mulga.cs.mu.OZ.AU
	id DAA11386; Wed, 4 Sep 2002 03:49:15 +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-NNTP-Posting-Date: 3 Sep 2002 14:56:41 GMT
Xref: archiver1.google.com comp.std.c++:13576

"Garry Lancaster" <glancaster@ntlworld.com> wrote in message news:<zllb9.458$S51.25977@newsfep1-gui.server.ntli.net>...
>
> (However, item 19 in Herb Sutter's "More Exceptional
> C++" explains why this can sometimes generate false
> positives. If you don't have the book the problem is
> shown by:
> 
> bar::~bar() {
>     try {
>         foo f;
>         // whatever.
>     } catch(...) {
>         // whatever.
>         if( !std::uncaught_exception() ) throw;
>     }
> }
> 
> If a bar is destroyed during stack unwinding, f's
> destructor will never throw, even though it is safe
> to do so.)
> 
> I don't think the proposal adds enough to what we
> already have to warrant its inclusion in the language.
> 

Doesn't your example shows that the situation is not simple? I know
the solution is to compare the situation as seen in the constructor
with the one in the destructor, but it involves a burden on all
classes. Each data member also has to keep it own private value. There
is also the problem of classes that I do not write, like standard
containers, althought I haven't encoutered problems so far in real
life.

The solution I proposed is just like yours, except it involves no
user-written code. It simplifies the language IMO: the destructors
cease to be special functions in respect to exceptions, as far as the
code writer is concerned. One less error for beginner and intermediate
programmers.

The current shortest solution is to defer all destructor code to
another function and use a function template taking an object and a
member-function pointer to do the try-catch-test-rethrow. The problem
here is that the function must be private to avoid bad calls and thus
the template with all its yucky syntax must be made friend.

Finally, the current code has a big "huh?" factor with newcomers, and
it easily forgotten in new classes.

---
[ 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                       ]



