Topic: Exception handling specs incomplete ?
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1996/04/06 Raw View
Alexander Krotoff <krotoff@boy.nmd.msu.ru> writes:
>I have two notes, about the behavior not specifed in the Jan 96 WP.
>1) While stack unwinding the destructor (or function indirectly called from
>the destructor) may try to do throw.
>As seems to me WP says nothing about this case. Is it allowed ?
>Is the behavior specified for this case ?
The section in the exceptions chapter describing the operation of
function terminate() says that from the point of the throw until the
exception handler is entered, if any user-written function exits via an
exception, terminate is called immediately. That includes your question.
>2) While stack unwinding the destructor may attempt to create
>new objects, or arrays of class objects with non-trivial destructors
>via operator new. Shall this outside exception affect creation of
>new objects ? (Inner exception will cause destructor calls for all
>already created base classes sub-objects and completely created array
>elements.
During stack unwinding, destructors for auto objects are called as
their block is exited. Those destructors do whatever they do. The
fact of being invoked as part of stack unwinding has only one
consequence: if the destructor exits via an exception, terminate() is
called. A destructor can call function uncaught_exception() to determine
whether exception handling is in progress. ("uncaught_exception() is
a recent addition to the draft standard, and I don't know of any
compilers that support it yet.)
--
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: Alexander Krotoff <krotoff@boy.nmd.msu.ru>
Date: 1996/04/05 Raw View
Hello c++ gurus,
I have two notes, about the behavior not specifed in the Jan 96 WP.
1) While stack unwinding the destructor (or function indirectly called from
the destructor) may try to do throw.
As seems to me WP says nothing about this case. Is it allowed ?
Is the behavior specified for this case ?
Example:
struct A {
~A () { throw 1; }
};
void f ()
{
A a;
throw 2;
}
main ()
{
f();
}
While stack unwinding control may come into the try-block.
Is it allowed ?
Shall this try-block hanlers be ignored ?
2) While stack unwinding the destructor may attempt to create
new objects, or arrays of class objects with non-trivial destructors
via operator new. Shall this outside exception affect creation of
new objects ? (Inner exception will cause destructor calls for all
already created base classes sub-objects and completely created array
elements.
Thank you in advance,
--
Alexander N. Krotoff krotoff@such.srcc.msu.su
Research Computer Center tel: +7(095)939-2638
Moscow State University fax: +7(095)939-4430
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]