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

boost::get overloads for boost::spirit::x3::variant should at least lack BOOST_NOEXCEPT #753

Open
blashyrkh-ravendark opened this issue Jan 27, 2023 · 0 comments

Comments

@blashyrkh-ravendark
Copy link

blashyrkh-ravendark commented Jan 27, 2023

Since boost::get may throw boost::bad_get (in the event of a failed application on the given arg), all boost::get overloads for refs or ptrs to boost::spirit::x3::variant objects in boost/spirit/home/x3/support/ast/variant.hpp should at least lack BOOST_NOEXCEPT (which leads to std::terminate invocation when a function indeed throws).

Example:

#include <boost/spirit/home/x3/support/ast/variant.hpp>
#include <iostream>

namespace x3 = boost::spirit::x3;

int main()
{
    x3::variant<bool, int> variant {5}; // Program crash
    // boost::variant<bool, int> variant {5}; // No issue

    try {
        const auto v = boost::get<bool>(variant);
    } catch(const boost::bad_get& e) {
        std::cerr << "boost bad_get: " << e.what() << std::endl;
        return 1;
    } catch(const std::exception& e) {
        std::cerr << "std exception: " << e.what() << std::endl;
        return 1;
    } catch(...) {
        std::cerr << "Unknown error";
        return 1;
    }

    return 0;
}
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

1 participant