Clang try catch fails

Here is the piece of code I'm talking about.

try { std::cerr << "first try" << std::endl; po::store(po::parse_config_file(ifs, _configFileOptions, false), vm); } catch(...) { std::cerr << "second try" << std::endl; } 

Just to find the details, I use boost program_options to parse the configuration file. The exception raises because I put the option in a file that is unrecognized.

There is a problem that Clang does not catch this exception. Mostly I see only the output

 first try libc++abi.dylib: terminating with uncaught exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::unknown_option> >: unrecognised option 'TestFrequency' Abort trap: 6 

Here is my version of clang:

 c++ --version Apple LLVM version 7.3.0 (clang-703.0.31) Target: x86_64-apple-darwin15.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin 

EDIT: when there is no exception, parsing and everything works fine.

+7
c ++ exception-handling clang
source share
1 answer

This could be due to an RTTI (runtime type information) issue that is similar to this issue with GoogleMaps or this issue to SO .

Make sure Boost and your code compiled without the fno-rtti flag.

0
source share

All Articles