Boost logo

Boost Users :

Subject: Re: [Boost-users] [TEST] Throws "Escaping" both BOOST_CHECK_THROW and try{}
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-02-10 20:19:25

On 10/02/2016 05:09, Merrill Cornish wrote:
> On 2/9/2016 12:58 AM, Gavin Lambert wrote:
>> Do you have a throw-specification or noexcept on the arcSize() method?
> I didn't have my own out-of-range check in the case of arcSize() since
> I deliberately used vector::at() which does its own check and raises
> std::out-of-range rather than use vector::operator[] which does not
> check. The original error message that started me looking into this was
> "terminate called after throwing an instance of 'std::out_of_range'", so
> the at() raised the exception I told the BOOST_CHECK_THROW to look for.

That's not what a throw-specification means. This is a clause on the
method itself that looks like "throw()" or "throw(some-exception-type)"
or "noexcept" etc.

If you have one of those on *any* method in the call chain between at()
and the test, then when at() throws an exception and this exception is
not caught by a method that has the throw-spec, then terminate() or
unexpected() (which in turn calls terminate() by default) will be
called. The message suggests that this is what is happening, which is
why I asked.

If you're still confused by this, then post the complete declaration and
definition (header and source) of the arcsSize method, and any other
methods between that and the std::vector::at() call.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at