Skip to content

Reverse include logic in throw_exception.hpp #315

@gaspardpetit

Description

@gaspardpetit

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions