From 4376867775016693593
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,9723061da44e5214
X-Google-Attributes: gidf78e5,public
From: Biju Thomas <b_thomas@ibm.net>
Subject: Re: Exception while throwing an exception?
Date: 1999/09/08
Message-ID: <37D598B6.C7E4921A@ibm.net>#1/1
X-Deja-AN: 522607733
X-NNTP-Posting-Host: 32.97.136.236
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <37D3E50E.A13D8AFC@prodigy.net> <slrn7t8m3o.too.sbnaran@localhost.localdomain> <37D56411.F9600F29@ibm.net> <user-0709991723500001@aus-as3-014.io.com>
X-UID: 0000000001
X-Status: $$$$
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@prserv.net
X-Trace: 7 Sep 1999 22:58:50 GMT, 32.97.136.236
Organization: None
Mime-Version: 1.0
Reply-To: b_thomas@ibm.net
Newsgroups: comp.std.c++
Originator: clamage@taumet


blargg wrote:
> 
> 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)

I re-read it again. I still don't understand how this paragraph handles
the case mentioned by Andy.

For information, here is the relevant part that I could find:

<quote>

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

   when the exception handling mechanism, after completing evaluation 
   of the expression to be thrown but before the exception is caught 
   (15.1), calls a user function that exits via an uncaught exception,

[... other cases ...]

In such cases, termiate() is called.

</quote>

Does the constructor for the exception object fall under the above rule?
I don't think so. OTOH, if a copy constructor of the exception object
that the exception handling mechanism invokes internally throws, that
falls under the above criteria, and, should call terminate().

May be I should learn how to read standards better :-)

> What do you think should be specified instead?

IMHO, it should handle the second exception that is thrown by the
constructor. 

Consider this case - the constructor for an exception object throws
std::bad_alloc. I think it is more prudent to propagate std::bad_alloc
than calling terminate().

-- 
Biju Thomas


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




