#12438 closed Bugs (fixed)
Wrong additional closing tag in boost::archive::xml_woarchive
| Reported by: | anonymous | Owned by: | Robert Ramey |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | serialization |
| Version: | Boost 1.62.0 | Severity: | Problem |
| Keywords: | Cc: | juergen.flieser@… |
Description
boost::archive::xml_woarchive writes an additional line </boost_serialization> after the closing tag </boost_serialization> The output of boost::archive::xml_oarchive is correct.
The ouput of xml_woarchive is
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!DOCTYPE boost_serialization> <boost_serialization signature="serialization::archive" version="14"> <w_foo class_id="0" tracking_level="0" version="0"></w_foo> </boost_serialization> </boost_serialization>
The source code is
// Boost: 1.62.0 BETA1
//
// Toolset: Microsoft Visual C++
// Microsoft Visual Studio Professional 2015
// Version 14.0.25425.01 Update 3
// Visual C++ 2015 00325 - 60002 - 24764 - AA687
// Microsoft Visual C++ 2015
// Behavior is in all configurations 32bit/64bit and debug/release
//
// ====================================================================
// Needed for <boost/archive/tmpdir.hpp>
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <boost/archive/tmpdir.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_woarchive.hpp>
// ====================================================================
class foo
{
public:
foo() {};
template<class Archive>
void serialize(Archive &ar, const unsigned int version) {}
};
// --------------------------------------------------------------------
void save_sfoo(const foo& s_foo, const std::string& filename)
{
std::ofstream ofs(filename);
boost::archive::xml_oarchive oa(ofs);
oa << BOOST_SERIALIZATION_NVP(s_foo);
}
// --------------------------------------------------------------------
void save_wfoo(const foo& w_foo, const std::string& filename)
{
std::wofstream ofs(filename);
boost::archive::xml_woarchive oa(ofs);
oa << BOOST_SERIALIZATION_NVP(w_foo);
}
// ====================================================================
int main(int argc, char *argv[])
{
foo some_foo;
std::string savedir(boost::archive::tmpdir());
std::cout << "Saving s_foo.xml and w_foo.xml to directory <" << savedir << ">" << std::endl;
save_sfoo(some_foo, savedir + "/sfoo.xml");
save_wfoo(some_foo, savedir + "/wfoo.xml");
return 0;
}
// ====================================================================
// Files created are
// ====================================================================
// "sfoo.xml"
// --------------------------------------------------------------------
/*
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="14">
<s_foo class_id="0" tracking_level="0" version="0"></s_foo>
</boost_serialization>
*/
// --------------------------------------------------------------------
// "wfoo.xml"
// --------------------------------------------------------------------
/*
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="14">
<w_foo class_id="0" tracking_level="0" version="0"></w_foo>
</boost_serialization>
</boost_serialization>
*/
Change History (6)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
The reported error is Boost 1.62 release (when I reported the error Boost 1.62 beta was in use).
comment:3 by , 6 years ago
Did you upgrade to the 1.62 final? The log shows that a fix was checked into the master (32b2bda) on April 21,2016. Is this fix not in your code? or does the "fix" fail to address the issue?
comment:4 by , 6 years ago
The latest 1.62 release we upgraded to is the final one, it is not a beta. We loaded it from https://sourceforge.net/projects/boost/files/boost-binaries/1.62.0/boost_1_62_0-bin-msvc-all-32-64.7z/download The timestamp is 2016-09-26. It has not been updated since then.
comment:5 by , 5 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
I've just tested this on my version on the develop branch and it IS fixed there.
I recently realized that due to an oversight on my part, some fixes on my local develop branch weren't merged and pushed. But I think that's fixed now. Unfortunately, this isn't in the latest release but it should be in the next one for sure.
Robert Ramey
comment:6 by , 5 years ago
I found same bug in version 1.62. I tried to use version 1.64 (downloaded from https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.7z) with same result (additional line).
I've modified the file .\boost_1_64_0\boost\archive\impl\xml_woarchive_impl.ipp as shown below and it works fine for me now.
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save(const wchar_t * ws){
os << ws;
/* next lines commented out to fix #12438 Wrong additional closing tag in boost::archive::xml_woarchive */
#if 0
typedef iterators::xml_escape<const wchar_t *> xmbtows;
std::copy(
xmbtows(ws),
xmbtows(ws + std::wcslen(ws)),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
#endif
}
#endif

this is clearly an error. I thought I fixed this in the final release of 1.61. Are you sure that you're not using one of pre-release betas? Does the issue still show up in the develop branch?