Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Newsgroups: comp.lang.c++ Subject: Exception Handling Message-ID: <62297@brunix.UUCP> Date: 23 Jan 91 14:39:28 GMT Sender: news@brunix.UUCP Reply-To: sdm@cs.brown.edu (Scott Meyers) Organization: Brown University Department of Computer Science Lines: 55 I'm trying to understand the proposed exception handling mechanism, and since I don't have access to an implementation, I have a couple of questions about exceptions, especially as regards constructors. Consider: class NoMoreMemory { ... }; // one class of exceptions class OtherException { ... }; // another class of exceptions // a class where the constructor may raise exceptions class Foo { public: Foo() throw (NoMoreMemeory, OtherException); }; // a global object whose construction may raise exceptions Foo globalFoo; // a function with local objects that may raise exceptions void f() { Foo local1; try { Foo local2; } catch (NoMoreMemory) { /* do something */ } catch (OtherException) { /* do something else */ } } Is it true that: 1. There is no way to catch exceptions raised during the construction of globalFoo except via calls to set_unexpected? 2. f cannot catch exceptions raised during the construction of local1 because that declaration isn't in a try block? 3. Any function can be declared to raise an exception, including operators new and delete and class destructors? 4. Assuming that it is legal for destructors to raise exceptions, you may get different behavior from such a destructor depending on whether it is called "normally" or as part of the stack unwinding process during the handling of another exception (ARM 15.6.1c)? Also, speaking of implementations, what's the state of g++ exception handling these days -- does it implement something akin to that described in chapter 15 of the ARM? Thanks, Scott ------------------------------------------------------------------------------- What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."