R
Rennie deGraaf
I know that if an exception is thrown from a destructor while unwinding
the stack because of another exception, terminate() is called (FAQ
17.3). How exactly does this rule work? Is it acceptable to both throw
/and/ catch an exception inside a destructor, as in the following code?
struct Foo
{
void finalize()
{
throw 1.0;
}
~Foo()
{
try
{
finalize();
}
catch (double d)
{}
}
};
void bar()
{
Foo f;
throw 1;
}
int main()
{
try
{
bar();
}
catch (int i)
{}
return 0;
}
Rennie deGraaf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFGNVl6IvU5mZP08HERAnkaAJ9rODkY55YL/ON+PXYS0ImI2K783QCgzAwr
6zQzt0Hkj6h8KYRFfI/xYw8=
=H9qr
-----END PGP SIGNATURE-----
the stack because of another exception, terminate() is called (FAQ
17.3). How exactly does this rule work? Is it acceptable to both throw
/and/ catch an exception inside a destructor, as in the following code?
struct Foo
{
void finalize()
{
throw 1.0;
}
~Foo()
{
try
{
finalize();
}
catch (double d)
{}
}
};
void bar()
{
Foo f;
throw 1;
}
int main()
{
try
{
bar();
}
catch (int i)
{}
return 0;
}
Rennie deGraaf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFGNVl6IvU5mZP08HERAnkaAJ9rODkY55YL/ON+PXYS0ImI2K783QCgzAwr
6zQzt0Hkj6h8KYRFfI/xYw8=
=H9qr
-----END PGP SIGNATURE-----