Catch block being bypassed on boost exception

Viewed 354

Environment: Windows 10, Visual Studio 2015, x64, Unicode, boost 1.64

I'm having problems determining why a catch block is not being hit when a boost exception is purposely attempted. The point it to let boost tell me if a source string for a date is of the wrong format.

Here is the code in question:

std::string sDate("01/03/2017");    // purposely bad date format, should be 2017/01/03
bool bGoodDate(true);
try
{
    boost::gregorian::date dtTemp(boost::gregorian::from_simple_string(sDate));
}
catch (const std::out_of_range& e)
{
    bGoodDate = false;
}
catch (...)
{
    bGoodDate = false;
}

When this code is in a stand-alone console program, it works. The out_of_range catch block is hit. But when the same code is in a Windows GUI app built with MFC in a static library (not sure that's relevant), the catch block is never hit. Instead, I see this boost exception wrapper referenced in an Unhandled Exception error thrown by the GUI app:

Unhandled exception at 0x00007FFC0BC09E08 in Journal.exe: Microsoft C++ exception: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::gregorian::bad_day_of_month> > at memory location 0x00000078A3DEB100.

I have compared the compiler, debugger and linker settings between the two projects, and there were no differences, other than the number of third party libraries being larger in the GUI project, and the few console-vs-gui settings needed to build the applications.

I found this seemingly related question/answer, but I'm not sure how I'd go about finding a solution based on that answer: Weird issue with catching trivial boost exception

Any ideas on how I could track down the cause of this behavior?

Thanks.

0 Answers
Related