"Richard Dingwall"
wrote in message news:aedf0bab0708212308s3193f314ma112d9a67c8f54ce@mail.gmail.com... The short of it is, that if you have a setup similar to the following ( i.e., an empty throw() clause on a template specialisation): template<class output_type> output_type do_something(int input_value) throw(std::invalid_argument); template<> int do_something(int input_value) throw(std::invalid_argument); template<> long do_something(int input_value) throw();
And attempt to test throwing a std::invalid_argument from within the long specialised function, e.g.:
// note: an argument less than zero will throw a std::invalid_argument BOOST_CHECK_THROW(do_something<long>(-1), std::invalid_argument);
You will see something the following:
Running 4 test cases... terminate called after throwing an instance of 'std::invalid_argument' what(): Input value too low. unknown location(0): fatal error in "long_throw": signal: SIGABRT (application abort requested) sigabrt_test_suite.cpp(58): last checkpoint
*** 1 failure detected in test suite "sigabrt tests"
My function is throwing a std::invalid_argument and my test case been programmed to catch it. But it doesn't. This had me scratching my head for a > few days, until I noticed the empty throw() clause. Completing it resolved the problem immediately.
I'm not sure if this is expected behaviour, but if anyone's interested, a test case is attached. I'm using gcc version 4.0.1 (Apple Computer, Inc. build > 5367) on a G4 Powerbook with whatever was in Boost's SVN trunk on August 6.
Ummm.... What are you complaining about essencially? I would say it's expected behavior. You throw an exception from function with nothrow declaration - you are going to end up in abort(). Which is what Boost.Test reported to you. Gennadiy