[serialization] exception in destructor

Hello Robert, I spent a lot of time trying to understand where my program failed. Finally, I found that the cause was in destructor of basic_xml_oarchive class: template<class Archive> #if !defined(__BORLANDC__) BOOST_DECL_ARCHIVE_OR_WARCHIVE #endif basic_xml_oarchive<Archive>::~basic_xml_oarchive(){ if(!header) return; this->This()->put("</boost_serialization>\n"); } basic_text_oprimitive::put(const char * s) can throw an exception, causing unexpected termination of program when stack unwind. I heard many times that uncaught exception in destructor is not very good thing. Should we consider refactoring of this point in basic_xml_oarchive? Regards. Slava. -- Vyacheslav E. Andrejev System Architect, Excelsior, LLC

Vyacheslav E. Andrejev wrote:
Hello Robert,
I spent a lot of time trying to understand where my program failed. Finally, I found that the cause was in destructor of basic_xml_oarchive class:
template<class Archive> #if !defined(__BORLANDC__) BOOST_DECL_ARCHIVE_OR_WARCHIVE #endif basic_xml_oarchive<Archive>::~basic_xml_oarchive(){ if(!header) return; this->This()->put("</boost_serialization>\n"); }
basic_text_oprimitive::put(const char * s) can throw an exception, causing unexpected termination of program when stack unwind. I heard many times that uncaught exception in destructor is not very good thing. Should we consider refactoring of this point in basic_xml_oarchive?
Regards. Slava.
Good Point Robert Ramey
participants (2)
-
Robert Ramey
-
Vyacheslav E. Andrejev