serialization - questionable basic_xml_oarchive dtor

Hello, All! I think that basic_xml_oarchive destructor can be more safe if uncaught_exception examination will be added, because put sometimes can throw exceptions: template<class Archive> basic_xml_oarchive<Archive>::~basic_xml_oarchive(){ if(!header) return; if (!std::uncaught_exception()) this->This()->put("</boost_serialization>\n"); } With best regards, Sergey.

Hello, Robert! You wrote on Fri, 11 Feb 2005 16:29:39 -0800: ??>> I think that basic_xml_oarchive destructor can be more safe if ??>> uncaught_exception examination will be added, because put sometimes ??>> can ??>> throw exceptions: ??>> ??>> template<class Archive> ??>> basic_xml_oarchive<Archive>::~basic_xml_oarchive(){ ??>> if(!header) ??>> return; ??>> if (!std::uncaught_exception()) ??>> this->This()->put("</boost_serialization>\n"); RR> What happens if this last statement throws another exception? It can't - last statement will not be executed if any thrown exception is being currently processed. But may be better solution is try { this->This()->put("</boost_serialization>\n"); } catch (archive_exception &) // or catch(std::exception) or even catch(..) - I'm not sure {} This should not prevent writing las tag if destructor called in stack unwinding process for exception that is not related to archive output operations. Current CVS version of basic_xml_oarchive destructor compel users to catch exceptions on every save - without it terminate() called if almost any output error occurs. With best regards, Sergey.
participants (2)
-
Robert Ramey
-
Sergey Skorniakov