Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!brl-adm!umd5!cvl!elsie!nih-csl!keith From: keith@nih-csl.UUCP (keith gorlen) Newsgroups: comp.lang.c++ Subject: Exception handling (was: OOPS gripes) Summary: Popping the exception frames is the easy part calling destructors causes the problem Message-ID: <306@nih-csl.UUCP> Date: 7 Feb 88 14:22:53 GMT References: <3117@okstate.UUCP> Organization: NIH-CSL, Bethesda, MD Lines: 36 In article <3117@okstate.UUCP>, norman@a.cs.okstate.edu (Norman Graham) writes: > in article , keith@nih-csl.UUCP (keith gorlen) says: > > > My inclination is to ignore the OOPS exception handling code as much > > as possible, and replace it when exception handling is incorporated > > into C++. > > I tried desperately to design a suitable (ie. simple, transparent, etc) > exception handling scheme for a project I'm involed with ( >80000 lines > of C source in >450 files). We wanted to use a stack of exception frames > and we would have, except for one problem... we couldn't guarentee that the > exception frame stack would be poped on each function return. Actually, popping the exception frame on each function return is the easy part. You just make exception frames instances of a class that has a destructor, and have the destructor update the exception frame stack. But don't get excited -- the real problem is that when an exception occurs and you want to jump out to an enclosing exception frame, there's no way to get the destructors of all the objects local to blocks that are going out of scope called without help from the compiler. Bjarne has mentioned in several papers and talks that he's working on exception handling for C++. An additional problem is that the C++ exception handling mechanism should work in situations where you have C and C++ functions calling one another, and the C functions don't understand C++ exception handling. -- Keith Gorlen phone: (301) 496-5363 Building 12A, Room 2017 uucp: uunet!ncifcrf.gov!nih-csl!keith National Institutes of Health Internet: keith%nih-csl@ncifcrf.gov Bethesda, MD 20892