Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable noexcept unit tests in Boost.Outcome, now exceptions globally disabled works in Boost.Exception #234

Open
teajay-fr opened this issue Aug 19, 2020 · 8 comments

Comments

@teajay-fr
Copy link

Compiling with BOOST_NO_EXCEPTIONS procuces the following output:

/home/bernard/CMakePackageCache/release/extern/Boost/1.73.0/baremetal-cortex-m0-gnu.9/Pkg/include/boost/throw_exception.hpp:180:84: error: no matching function for call to 'throw_exception(const char [24], boost::source_location)'
  180 | #define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x, BOOST_CURRENT_LOCATION)
      |                                                                                    ^
/home/bernard/CMakePackageCache/release/extern/Boost/1.73.0/baremetal-cortex-m0-gnu.9/Pkg/include/boost/outcome/experimental/../config.hpp:320:45: note: in expansion of macro 'BOOST_THROW_EXCEPTION'
  320 | #define BOOST_OUTCOME_THROW_EXCEPTION(expr) BOOST_THROW_EXCEPTION(expr)
      |                                             ^~~~~~~~~~~~~~~~~~~~~
/home/bernard/CMakePackageCache/release/extern/Boost/1.73.0/baremetal-cortex-m0-gnu.9/Pkg/include/boost/outcome/experimental/status_result.hpp:120:13: note: in expansion of macro 'BOOST_OUTCOME_THROW_EXCEPTION'
  120 |             BOOST_OUTCOME_THROW_EXCEPTION("wide value check failed");
@teajay-fr
Copy link
Author

I've investigated a bit further and it seems that the BOOST version doesn't include the the tests for disabled exceptions. Running the tests from this repository showed that when exceptions are disabled every thing is fine.

@teajay-fr
Copy link
Author

teajay-fr commented Aug 19, 2020

Further analysis showed that this version of outcome is OK. It's the boost implementation which has a problem.

To reproduce the error just add this following lines the test directory jam file:

 [ run tests/experimental-core-result-status.cpp : : : <rtti>off <exception-handling>off <define>BOOST_NO_RTTI <define>BOOST_NO_EXCEPTIONS ]

I think the outcome-status has the same issue.

@ned14
Copy link
Owner

ned14 commented Aug 19, 2020

Boost.Exception fixed this in boostorg/exception@3300084, but it had to be reverted for the Boost 1.74 release last week. Now that is released, the fix is live. And Boost 1.75 will have it.

Standalone Outcome has worked fine on exceptions globally disabled for years now, if that helps.

Re: Enabling the noexcept tests in Boost.Outcome, that is a good idea now that is actually possible, and I will rename this issue accordingly. Thanks for the report!

@ned14 ned14 changed the title When exceptions are disabled the status_result fails to compile Enable noexcept unit tests in Boost.Outcome, now exceptions globally disabled works in Boost.Exception Aug 19, 2020
@apmanol
Copy link

apmanol commented Mar 22, 2022

Hello,

trying to use boost::outcome in 1.75 but I can't compile without exceptions

c++ -DBOOST_ASIO_HEADER_ONLY -DBOOST_ASIO_NO_DEPRECATED -DBOOST_ASIO_NO_IOSTREAM -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_NO_EXCEPTIONS  -O2 -g -DNDEBUG -fno-exceptions -std=gnu++17 
smi_message.cpp


In file included from /usr/include/boost/exception_ptr.hpp:9,
                 from /usr/include/boost/outcome/boost_result.hpp:37,
                 from /usr/include/boost/outcome/result.hpp:34,
                 from /usr/include/boost/outcome/outcome.hpp:34,
                 from /utils/smi_client/smi_client.hpp:8,
                 from /utils/smi_client/smi_message.cpp:14:
/usr/include/boost/exception/detail/exception_ptr.hpp:12:2: error: #error This header requires exception handling to be enabled.
   12 | #error This header requires exception handling to be enabled.

Do I miss some -Dflag to help skipping this #include ?

@ned14
Copy link
Owner

ned14 commented Mar 22, 2022

@apmanol I vaguely remember it had to be reverted for the 1.75 release as well for some reason, but it's definitely working now. @zajo Can you tell us what might be happening here?

@zajo
Copy link

zajo commented Mar 22, 2022

Try with the latest release please, let me know.

@apmanol
Copy link

apmanol commented Mar 23, 2022

Try with the latest release please, let me know.

Thank you very much for your prompt answers!

Unfortunately, the project toolchain has 1.75 version, so it's not possible to change/experiment with something different.

Anyway, I used the single header approach, that works as it should with -fno-exceptions.

@zajo
Copy link

zajo commented Mar 23, 2022

The support for boost::exception_ptr under -fno-exceptions is a new thing, though I didn't take a note in which Boost release it was introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants