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

Reverse include logic in throw_exception.hpp #315

Open
gaspardpetit opened this issue Jun 8, 2024 · 1 comment
Open

Reverse include logic in throw_exception.hpp #315

gaspardpetit opened this issue Jun 8, 2024 · 1 comment

Comments

@gaspardpetit
Copy link

gaspardpetit commented Jun 8, 2024

I believe commit b4412f2 by @jzmaddock introduced a bug in the include logic - the ifndef should have been changed for an ifdef. The fact that it has been there for 2 years without anyone complaining makes me doubt, so let me know what you think :D

See my note here: b4412f2#r142878767

Essentially the code looks like this:

#ifndef BOOST_NO_EXCEPTIONS
#include <boost/throw_exception.hpp>
#endif

namespace boost {
namespace serialization {

#ifdef BOOST_NO_EXCEPTIONS

BOOST_NORETURN inline void throw_exception(std::exception const & e) {
    ::boost::throw_exception(e);
}

#else

template<class E> BOOST_NORETURN inline void throw_exception(E const & e){
    throw e;
}

#endif

} // namespace serialization
} // namespace boost

We need the include when we are going to call ::boost::throw_exception(e); which gets called only when defined(BOOST_NO_EXCEPTIONS) is true. Therefore, it seems like the include should be on an ifdef rather than an ifndef.

@jzmaddock
Copy link
Contributor

I think you're correct - my bad - the error has probably been hidden because almost everything in boost includes boost/throw_exception.hpp anyway!

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

No branches or pull requests

2 participants