From 1682498436446284955
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,9723061da44e5214
X-Google-Attributes: gidf78e5,public
From: postmast.root.admi.gov@iname.com (blargg)
Subject: Re: Exception while throwing an exception?
Date: 1999/09/07
Message-ID: <user-0709991723500001@aus-as3-014.io.com>#1/1
X-Deja-AN: 522297647
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <37D3E50E.A13D8AFC@prodigy.net> <slrn7t8m3o.too.sbnaran@localhost.localdomain> <37D56411.F9600F29@ibm.net>
X-Original-Date: Tue, 07 Sep 1999 17:23:49 -0500
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: ariel.ucs.unimelb.edu.au 936743863 9057 128.250.37.153 (7 Sep 1999 22:37:43 GMT)
Organization: e-mail address IS valid - but fools the spammers
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN9WTpOEDnX0m9pzZAQH0kwF+I07MjMWXjSV/NokC4tPR0dIsIrvnd4Xq cvSlpV9v66kAa8D3FRQF0dIHClMTnC/m =A4Lu
NNTP-Posting-Date: 7 Sep 1999 22:37:43 GMT
Newsgroups: comp.std.c++

In article <37D56411.F9600F29@ibm.net>, b_thomas@ibm.net wrote:

> Siemel B. Naran wrote:
> > 
> > On 6 Sep 1999 20:53:57 GMT, Andy Larson <AndyLarson@prodigy.net> wrote:
> > 
> > >What is the required behavior when the constructor of an exception
> > >object throws an exception?  For example, if an exception is thrown as
> > >in
> > 
> > The required behaviour is a call to std::terminate().
> 
> I can't find such a specification in the standard. Can you tell where
> you found it?

In the section describing std::terminate() (15.5.1)

> > Coding guideline: try to make your exception objects not throw.
> > To avoid risking to throw an out-of-memory or std::bad_alloc,
> > avoid dynamic memory in the exception object.
> > 
> > Coding guideline: try to make your destructors of exception as
> > well as non-exception objects not throw.  If an object is being
> > destroyed because of an exception already in progress, then if
> > the destructor throws, we have two exceptions.  The result is a
> > call to std::terminate().
> 
> Agreed with the guidelines. But, the standard specifying so is a bit
> extreme.

What do you think should be specified instead?

As it says in the introduction for std::terminate,

"In the following situations exception handling must be abandoned for less
subtle error handling techniques."

Bjarne also discusses this reasoning in C++PL 2nd on page 322, C++PL 3rd
page 373 (specifically addressing exceptions in destructors), and on page
383 (essentially the same discussion mentioned above as in C++PL 2nd)

If you want something different to happen in this case, you are certainly
free to handle it differently yourself (within the constraints of the
language). I see exceptions as being, at the core, a non-local goto
(without any type information). The type information is an extra benefit
that can be handled explicitly in some other fashion by the programmer.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]



