comp.lang.ada
 help / color / mirror / Atom feed
From: Hyman Rosen <hyrosen@mail.com>
Subject: Re: Weird controlled behavior - Gnat 3.15p NT
Date: Thu, 11 Sep 2003 03:40:56 GMT
Date: 2003-09-11T03:40:56+00:00	[thread overview]
Message-ID: <c9S7b.13977$w41.2212@nwrdny02.gnilink.net> (raw)
In-Reply-To: <1aujjb.m2u.ln@skymaster>

Jean-Pierre Rosen wrote:
> And what happens in C++ when an exception is raised by a destructor,
> for this object and for objects not yet finalized?

It is considerd very bad design in C++ to allow exceptions to escape
from destructors, because of the poor semantic meaning of such a thing.
(While you may fail to construct something and so have no object, when
the compiler says it's time to destroy something, it's gone.)

In any case, should an exception be thrown from a destructor, the code
goes on to call destructors for the remaining completely constructed
subobjects of the throwing object, if any, then for other objects whose
lifetimes are ending due to the scope being exited because of the thrown
exception. Should one of those destructors again throw, the special global
function terminate() is called, and the program ends.

I believe that in similar circumstances, Ada does all the finalizations
and then raises Program_Error, so in both languages, Don't Do That (tm).




  reply	other threads:[~2003-09-11  3:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-04 15:25 Weird controlled behavior - Gnat 3.15p NT Jano
2003-09-04 15:40 ` Martin Krischik
2003-09-04 18:06 ` Patrice Freydiere
2003-09-04 19:03   ` Jano
2003-09-04 20:57     ` Jano
2003-09-05  8:48     ` Preben Randhol
2003-09-05 13:48       ` Jano
2003-09-04 21:36 ` Robert I. Eachus
2003-09-05  4:04   ` Randy Brukardt
2003-09-05 13:48     ` Jano
2003-09-05 14:33       ` Dmitry A. Kazakov
2003-09-09  2:01   ` Hyman Rosen
2003-09-09  7:02     ` Jean-Pierre Rosen
2003-09-11  3:40       ` Hyman Rosen [this message]
2003-09-09  8:22     ` Dmitry A. Kazakov
2003-09-11  3:46       ` Hyman Rosen
2003-09-11  8:23         ` Dmitry A. Kazakov
2003-09-05  7:10 ` Jean-Pierre Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox