|
Boost Users : |
From: Holmes, Michael A \(Mike\) (mikeholmes_at_[hidden])
Date: 2004-12-08 11:27:21
I don't know is this is a bug as such, but thought I should bring it up.
I boiled down an un handled exception I was receiving in VC 7.1 and
related it to the demo.cpp
The demo does not close or flush the ofstream before it reads back from
the same file it wrote to, this appears to work correctly for the demo,
but in the attached very simple case it does not. I am assuming that it
is because the ofstream did not get flushed and the file contains no
data.
I think that adding a flush or close would make the demo more robust and
complete.
int _tmain(int argc, _TCHAR* argv[])
{
std::string filename(boost::archive::tmpdir());
filename += "/demofile.txt";
std::string b1("mike");
std::ofstream ofs(filename.c_str());
boost::archive::text_oarchive oa(ofs);
oa << b1;
// FIX
ofs.flush();
ofs.close(); // Without either of these VC7.1 gives
// Unhandled exception at 0x77e738b2 in
bstTest.exe: Microsoft C++ exception: //
boost::archive::archive_exception @ 0x0012f7bc. "
// END FIX
std::string b3;
std::ifstream ifs(filename.c_str());
boost::archive::text_iarchive ia(ifs);
ia >> b3;
}
Call stack ->
bstTest.exe!boost::throw_exception<boost::archive::archive_exception>(co
nst boost::archive::archive_exception & e={...}) Line 40 C++
bstTest.exe!boost::archive::detail::common_iarchive<boost::archive::text
_iarchive>::init() Line 69 + 0x31 C++
bstTest.exe!boost::archive::text_iarchive_impl<boost::archive::text_iarc
hive>::text_iarchive_impl<boost::archive::text_iarchive>(std::basic_istr
eam<char,std::char_traits<char> > & is={...}, unsigned int
flags=0x00000000) Line 70 C++
bstTest.exe!boost::archive::text_iarchive::text_iarchive(std::basic_istr
eam<char,std::char_traits<char> > & is={...}, unsigned int
flags=0x00000000) Line 82 + 0x33 C++
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net