red floyd wrote:
This is actually more of a question:
Won't this code always throw an exception? and
(in later posts) Serge says the output is:
Exception cought: Too bad!
Shouldn't this be (I really ought to compile this myself and see).
I don't think so. I don't have chapter&verse from the Standard, but I
believe the exception handler is executed *after* the try block is exited.
I've pinpoited the problem to the difference in style
i.e whether a smart pointer is declared out of if statement or
within the if statement:(
The original code where I ran into this problem uses
boost::smart_ptr heavily. It seems to be related to the
boost::smart_ptr except the sample works fine with several
compilers other than bcc32 5.6.4:(
I attached the examples for info, please note that boosttest.cpp
and boosttest2.cpp work fine with Borland C++ 5.6.4 while
boosttest1.cpp does not (the shared_ptr that is allocated within
the try block is not cleaned up).
I've sent the message to boost users list and the decision is
that it is a strange borland bug (so far).
Thanks for discussing the problem.