Программа boost :: thread аварийно завершает работу при выдаче std :: exception

Я не понимаю, почему эта программа дает сбой. Это вся программа

#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
boost: пробовал как 1.44.0, так и 1.46.1
Связывание (пробовали как динамический, так и статический)

5
задан user754425 22 May 2011 в 10:05
поделиться