Question

We are testing a very simple serialization code with boost::serialization. The test simply writes a std::string in a file.

It compiles ok but the problem is that it throws an exception when << operator is called. The file remains empty.

Unhandled exception in 0x1004b370 (msvcr100d.dll) 0x000000000021647a in test.exe: 0xC0000005: Access violation in 0x000000000021647a

We are using boost 1.53 libraries compiled with visualc++2010 in windows 7 64 bits. Also tried with Intel 12.1 64 bits with no success.

#include <fstream> 
#include <boost/serialization/string.hpp>
#include <boost/archive/text_oarchive.hpp> 

int main(int argc, char * argv[])
{
    std::string s = "HelloWorld!"; 

    std::ofstream file("archive.txt"); 
    boost::archive::text_oarchive oa(file); 

    oa << s;

    file.close();
}

Any help?

Was it helpful?

Solution

We've found that the problem went with the preprocess directive _HAS_ITERATOR_DEBUGGING=0 we were using at our project. When used, the fstream doesnt work well. Any ideas why? Is this a bug in fstream (unlikely)?. Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top