diff --git a/include/boost/decimal/detail/comparison.hpp b/include/boost/decimal/detail/comparison.hpp index a23b6aebc..41bec656e 100644 --- a/include/boost/decimal/detail/comparison.hpp +++ b/include/boost/decimal/detail/comparison.hpp @@ -96,7 +96,7 @@ template std::enable_if_t::value || std::is_same::value || std::is_same::value, bool> { - using comp_type = typename DecimalType::significand_type; + using comp_type = std::conditional_t<(std::numeric_limits::digits10 > std::numeric_limits::digits10), T1, T2>; BOOST_DECIMAL_ASSERT(lhs_sig >= 0); BOOST_DECIMAL_ASSERT(rhs_sig >= 0); diff --git a/test/Jamfile b/test/Jamfile index ac6bc9f10..ee3dccf89 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -49,6 +49,7 @@ run crash_report_1.cpp ; run github_issue_426.cpp ; run github_issue_448.cpp ; run-fail github_issue_519.cpp ; +run github_issue_799.cpp ; run link_1.cpp link_2.cpp link_3.cpp ; run quick.cpp ; run random_decimal32_comp.cpp ; diff --git a/test/github_issue_799.cpp b/test/github_issue_799.cpp new file mode 100644 index 000000000..194c01268 --- /dev/null +++ b/test/github_issue_799.cpp @@ -0,0 +1,40 @@ +// Copyright 2025 Matt Borland +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#ifdef BOOST_DECIMAL_HAS_INT128 + +template +void mixed_compare() +{ + const Dec a{2, 1}; + const auto b = __uint128_t{std::numeric_limits<__uint128_t>::max() - std::numeric_limits::max() + 20}; + BOOST_TEST(a != b); +} + +int main() +{ + using namespace boost::decimal; + + mixed_compare(); + mixed_compare(); + mixed_compare(); + mixed_compare(); + mixed_compare(); + mixed_compare(); + + return boost::report_errors(); +} + +#else + +int main() +{ + return 0; +} + +#endif