Re: [boost] [Boost.Config] Detect compiler support for std::current_exception
However, in my test I throw and catch exceptions: But the CI jobs have gcc and clang configured to compile without
exception
support!
I have two questions:
1) Where are exceptions disabled in the CI jobs? I can't find it in the .travis.yml, but I can see e.g. clang being invoked with -fno-exceptions
It's in the test/Jamfile.v2 file, look for <exception-handling>off.
Thanks!
2) How can I test proper support for std::current_exception() and std::rethrow_exception() if exceptions are disabled for the test?
You should probably condition your test on BOOST_NO_EXCEPTIONS and make the test no-op when exceptions are disabled.
But that defeats the whole purpose of having tests. I think I should at least use the type std::exception_ptr, and make sure the functions std::current_exception() and std::rethrow_exception() exist (even if I cannot test that they actually work as expected at runtime). I think the following should work, and at least the test tests something when exceptions are off: using std::exception_ptr; auto current = &std::current_exception; auto rethrow = &std::rethrow_exception; What do you think?
On 6/17/19 1:09 PM, dariomt--- via Boost wrote:
2) How can I test proper support for std::current_exception() and std::rethrow_exception() if exceptions are disabled for the test?
You should probably condition your test on BOOST_NO_EXCEPTIONS and make the test no-op when exceptions are disabled.
But that defeats the whole purpose of having tests.
Not really. You would still test the facilities when exceptions are enabled. OTOH, I don't see why would anyone care about these components when exceptions are disabled.
I think I should at least use the type std::exception_ptr, and make sure the functions std::current_exception() and std::rethrow_exception() exist (even if I cannot test that they actually work as expected at runtime).
I think the following should work, and at least the test tests something when exceptions are off:
using std::exception_ptr; auto current = &std::current_exception; auto rethrow = &std::rethrow_exception;
What do you think?
If it works, that would be fine by me. I don't disable exceptions and I don't know whether the standard library components related to exceptions stay available when exceptions are disabled. I wouldn't be surprised if they don't (now or in a future version of the standard library implementation). In any case, as I said, I don't see anyone using these components when exceptions are disabled, so not much point in testing.
participants (2)
-
Andrey Semashev
-
dariomt@gmail.com