Article View: comp.std.c++
Article #726Re: Exception Specifications
From: Johan Bengtsson
Date: Thu, 01 Oct 1992 11:47
Date: Thu, 01 Oct 1992 11:47
50 lines
2935 bytes
2935 bytes
jss@lucid.com (Jerry Schwarz) writes: : : The later included the only people (a medical software group at HP) : with experience using exceptions in C++. I asked them whether "out : of memory" had to always be included on their lists and they said : they didn't treat "out of memory" as an exception. I think the issue is broader than that. It is likely (IMO) that certain "system failure" exceptions will occur at unexpected times. Examples include "out of memory", "invalid pointer dereference", "divide by zero", "OODB deadlock" etc. For a program where it is unacceptable to terminate when this happens, the ARM provides the opportunity to replace the predefined unexpected() function with a custom one. Suppose you wish to nevertheless propagate these exceptions to a CATCH block, no matter what the exception specifications say. Is it OK for unexpected() to simply rethrow the exception? If this is _not_ allowed, then I'm afraid many functions (for example in life-critical systems) _must_ specify every "system failure" like exception, causing an avalanche of these throughout the entire program. Commercial libraries will need these too (to enable the broadest usage). : At the moment X3J16 is considering the implications of exceptions : for stream classes. Some think that streams should only : be able to throw a particular kind of exception (tentatively : named ios::failure). Others (including myself) feel that a stream : should be able to throw an arbitrary exception. Remember, users : can define their own kinds of streambufs, so X3J16 can't know in advance : what kinds of conditions they might want to report. But they may inherit their exception types from ios::failure, no? Does bring more structure to stream error handling, IMHO. Derived streambufs will be required to catch and translate non-ios exceptions. : [...]This leads me to the conclusion that the iostream library : should not use failure clauses. But this means every function using streams must catch all exceptions, or refrain from using exception clauses, and the functions calling those functions, and so on. We end up with programs with either a lot CATCH blocks, or very few failure clauses. -- -------------------------------------------------------------------------- | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden | | Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490 | --------------------------------------------------------------------------
Technical Details
Message-ID:
<5034@holden.lulea.trab.se>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!hagbard!loglule!jbnReferences:
<1992Sep30.205656.10646@lucid.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!hagbard!loglule!jbn From: jbn@lulea.trab.se (Johan Bengtsson) Newsgroups: comp.std.c++ Subject: Re: Exception Specifications Message-ID: <5034@holden.lulea.trab.se> Date: 1 Oct 92 11:47:28 GMT References: <1992Sep30.205656.10646@lucid.com> Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden Lines: 50 X-Newsreader: Tin 1.1 PL4