Serge Skorokhodov wrote:
Hi all,
I've encountered a situation when destructors to local objects are not called after an exception is raised. I use Borland C++ version 5.6.4 (Borland C++Builder 6). The examples are compiled with following command to ensure that destructor cleanup is on:
bcc32 -RT -x -xd -I
boosttest.cpp bcc32 -RT -x -xd -I boosttest1.cpp The code is attached. [...]
The problem is that the object created with the line
"shared_ptr<A> spa(new A("Local shared_ptr<A> destroyed!"));"
is destroyed in boosttest.cpp and is not destroyed in boosttest1.cpp. If shared_ptr is replaced with plain pointer, everything works fine (see boosttest2.cpp).
I would appreciate explaining what's wrong in my code.
Your code seems correct, and all non-Borland compilers agree. This looks like a particularly evil bcc32 bug.