|
Boost : |
From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2003-10-08 15:02:27
Peter Dimov wrote:
[...]
> Consider:
>
> void f() throw(X); // calls g
> void g() throw(Y); // calls h
> void h() throw(Z); // throws Z();
>
> The Z exception hits the throw(Y) wall; unexpected() eats the Z and throws
> Y.
Only if there was no other unexpected handler active by the time
something inside h() throws Z. And, BTW, by the time Z hits the
throw(Y) wall, your RAII object that sets/resets g()'s unexpected
handler is absolutely gone; dead completely. What's left is just
a silly pointer that was saved at Z's throw point... hmmm, and
what about "some associated resources", if any?
> Y hits throw(X), unexpected() now throws a X.
>
> If you invoke unexpected() before the unwinding, there is no way you can get
> an exception to escape through the three ex.specs.
Why not simply catch Z/throw Y in g() and catch Y/throw X in f()?
No brainer, oder?
regards,
alexander.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk