Article View: comp.std.c++
Article #132Re: constructors and exceptions
From: Mark Mendell
Date: Fri, 21 Aug 1992 03:25
Date: Fri, 21 Aug 1992 03:25
40 lines
2161 bytes
2161 bytes
Real working exception handling in the IBM xlC C++ compiler on the RS/6000: In article <2286@devnull.mpd.tandem.com> you write: > >Could one of the ANSI-C++ folks that have "paper experience" :-) >with how exception handling is supposed to work give a summary of how >will an exception thrown from a constructor interact with objects >previously constructed in the same "try" block. An exception in a constructor will destroy the object being constructed (as far as it has been constructed), then destroy all previously constructed objects in the try block, and then try matching the catch clauses. This will repeat up the static and dynamic blocks until a catch block is found that matches the exception, or else terminate() will be called. > >Also would you please illuminate us on how an exception thrown from >the constructor of a derived object (which executes after the construction >of the base object) interacts with the destruction of the base object. >Will the destructor for the base object be called when the exception >is thrown? Any part of the object that has been created will be destroyed (in reverse order). In particular the base destructor will be called, but not the derived destructor, because the derived object isn't completely contructed yet. > >What about an exception thrown from a signal handler (yuck!) that >interrupted the construction of an object? Under xlC, you are not allowed to do a throw from a signal handler. This restriction is due to the implementation of exception handling. Different implementations might allow you to do this. On the other hand, the only portable action allowed by ANSI C in a signal handler is to set a variable of type sigatomic_t. -- Mark Mendell IBM Toronto Lab mendell@torolab6.vnet.ibm.com
Technical Details
Message-ID:
<1992Aug20.232503.23209@jarvis.csri.toronto.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!utcsri!turing.toronto.edu!mendellReferences:
<2286@devnull.mpd.tandem.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!turing.toronto.edu!mendell Newsgroups: comp.std.c++ From: mendell@turing.toronto.edu (Mark Mendell) Subject: Re: constructors and exceptions Message-ID: <1992Aug20.232503.23209@jarvis.csri.toronto.edu> Organization: IBM Toronto Lab References: <2286@devnull.mpd.tandem.com> Date: 21 Aug 92 03:25:04 GMT Lines: 40