Я озадачен, почему эта программа падает. Это вся программа
#include<fstream>
#include<string>
#include<iostream>
#include <exception>
#include <boost/thread/thread.hpp>
void func( const std::string& filename )
{
std::ofstream outFile( filename.c_str(), std::ios::binary);
if( !outFile.is_open() )
{
std::string err("Could not open file ");
err.append(filename);
err.append(" for writing");
throw std::exception(err.c_str());
}
}
int main()
{
std::string filename("xX:\\does_not_exist.txt");
try
{
boost::thread thrd(boost::bind(&func, filename ));
thrd.join();
// func( filename ); // calling this does not cause a crash
}
catch( const std::exception& ex)
{
std::cout << ex.what() << std::endl;
}
return 0;
}
Окружающая среда
Windows 7
Visual Studio Express 2008
буст: пробовал и 1.44.0 и 1.46.1
Связывание (пробовал как динамическое, так и статическое)