0

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?

auroras
  • 51
  • 3
  • compilation parameters? – didierc Apr 17 '13 at 15:41
  • boost has been compiled with following line from downloaded folder: bjam.exe variant=debug link=shared threading=multi runtime-link=shared --stagedir=./ --build-type=complete --with-serialization address-model=64 – auroras Apr 17 '13 at 15:46
  • 1
    Do you get the same crash when using `stringstream` instead of `ofstream`? – Igor R. Apr 17 '13 at 16:00
  • That code compiles and run fine on my system (linux, boost 1.44), hence my request of the compilation flags. – didierc Apr 17 '13 at 16:04

1 Answers1

0

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

auroras
  • 51
  • 3