Notes about __cxa_end_catch
Coleen Phillimore
coleen at zko.dec.com
Thu Dec 16 19:58:46 UTC 1999
/*
Regarding the discussion of __cxa_end_catch:
If you need to clean up more than one live exception from a
catch handler, don't you need a 'count' parameter to
__cxa_end_catch? In this case, you destroy both X and
Y objects (whether or not they're both on the stack,
or just X is).
Our equivalent of end_catch has a count parameter which
is set to the number of live exception objects to
delete and is used for branching out of the nested catch
clause (not by rethrow).
*/
struct X { X(); ~X(); };
struct Y { Y(); ~Y(); };
extern "C" int printf(const char *,...);
main()
{
try {
throw X();
} catch (X x) {
try {
throw Y();
} catch(...) {
//generates __cxa_end_catch(/*levels=*/2)
return 1;
}
}
}
--
-----------------------------------------------------------------------
Coleen Phillimore | mailto:coleen at zko.dec.com
Compaq Computer Corp. Nashua, NH | COMPAQ C++ Compiler Development
-----------------------------------------------------------------------
More information about the cxx-abi-dev
mailing list