diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 5f1a02ec2..fbf7841a0 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -3,6 +3,7 @@ # Copyright 2021 Alexander Grund # Copyright 2022 James E. King III # Copyright 2023 Matt Borland +# Copyright 2026 Christopher Kormanyos # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) @@ -93,7 +94,7 @@ jobs: fi git config --global pack.threads 0 - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: # For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary' fetch-depth: ${{ matrix.coverage && '0' || '1' }} @@ -107,7 +108,7 @@ jobs: restore-keys: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}- - name: Fetch Boost.CI - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: boostorg/boost-ci ref: master diff --git a/.github/workflows/multiprecision.yml b/.github/workflows/multiprecision.yml index 391708eb4..99220e544 100644 --- a/.github/workflows/multiprecision.yml +++ b/.github/workflows/multiprecision.yml @@ -1,7 +1,7 @@ # Copyright 2020 Evan Miller # Copyright 2020 Matt Borland # Copyright 2021 John Maddock -# Copyright 2021 Christopher Kormanyos +# Copyright 2021, 2026 Christopher Kormanyos # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) @@ -31,7 +31,7 @@ jobs: compiler: [ g++-14 ] suite: [ specfun_mpfr, specfun_gmp, specfun_cpp_dec_float, specfun_cpp_bin_float, specfun_float128, specfun_cpp_double_double ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Set TOOLSET @@ -93,7 +93,7 @@ jobs: standard: [ c++14, c++17 ] suite: [ github_ci_block_1, github_ci_block_2 ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Set TOOLSET @@ -155,7 +155,7 @@ jobs: standard: [ c++17, c++20 ] suite: [ specfun_mpfr, specfun_gmp, specfun_cpp_dec_float, specfun_float128, specfun_cpp_double_double ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Set TOOLSET @@ -217,7 +217,7 @@ jobs: standard: [ c++14, c++17, c++20, c++23 ] suite: [ standalone ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Set TOOLSET @@ -279,7 +279,7 @@ jobs: standard: [ c++20 ] suite: [ arithmetic_tests, functions_and_limits, conversions, cpp_int_tests, misc ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Set TOOLSET @@ -341,7 +341,7 @@ jobs: standard: [ c++20 ] suite: [ arithmetic_tests, functions_and_limits, misc ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Set TOOLSET @@ -405,7 +405,7 @@ jobs: standard: [ 14, 17 ] suite: [ github_ci_block_1, github_ci_block_2 ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Checkout main boost @@ -448,7 +448,7 @@ jobs: standard: [ 14, 17, 20 ] suite: [ github_ci_block_1, github_ci_block_2 ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Checkout main boost @@ -486,7 +486,7 @@ jobs: standard: [ 14, 17, 2a ] suite: [ github_ci_block_1, github_ci_block_2 ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: '0' - name: Checkout main boost diff --git a/include/boost/multiprecision/cpp_int.hpp b/include/boost/multiprecision/cpp_int.hpp index efcf50cad..f6bfdc433 100644 --- a/include/boost/multiprecision/cpp_int.hpp +++ b/include/boost/multiprecision/cpp_int.hpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////// // Copyright 2012 - 2022 John Maddock. -// Copyright 2022 Christopher Kormanyos. +// Copyright 2022, 2026 Christopher Kormanyos. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -393,14 +393,14 @@ struct cpp_int_base > BOOST_MP_LIT(_cppi, Bits)() \ { \ using pt = typename boost::multiprecision::literals::detail::make_packed_value_from_str::type; \ - return boost::multiprecision::literals::detail::make_backend_from_pack< \ - pt, \ - boost::multiprecision::backends::cpp_int_backend >::value; \ + using local_backend_type = boost::multiprecision::backends::cpp_int_backend; \ + auto result { boost::multiprecision::literals::detail::make_backend_from_pack::value }; \ + result.normalize(); \ + return result; \ } \ template \ constexpr boost::multiprecision::number > BOOST_MP_LIT(_cppui, Bits)() \ { \ using pt = typename boost::multiprecision::literals::detail::make_packed_value_from_str::type; \ - return boost::multiprecision::literals::detail::make_backend_from_pack< \ - pt, \ - boost::multiprecision::backends::cpp_int_backend >::value; \ + using local_backend_type = boost::multiprecision::backends::cpp_int_backend; \ + auto result { boost::multiprecision::literals::detail::make_backend_from_pack::value }; \ + result.normalize(); \ + return result; \ } BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(128) BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(256) +BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(384) BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(512) BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(1024) #undef BOOST_MP_LIT diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1feb0bcc1..a78e60441 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1283,6 +1283,7 @@ test-suite misc : [ run git_issue_734.cpp ] [ run git_issue_743.cpp : : : [ check-target-builds ../config//has_float128 : quadmath : no ] ] [ run git_issue_759.cpp : : : [ check-target-builds ../config//has_float128 : quadmath : no ] ] + [ run git_issue_766.cpp ] [ compile git_issue_98.cpp : [ check-target-builds ../config//has_float128 : TEST_FLOAT128 quadmath : ] [ check-target-builds ../config//has_gmp : TEST_GMP gmp : ] diff --git a/test/git_issue_766.cpp b/test/git_issue_766.cpp new file mode 100644 index 000000000..4a4f3662a --- /dev/null +++ b/test/git_issue_766.cpp @@ -0,0 +1,63 @@ +//////////////////////////////////////////////////////////////// +// Copyright 2026 Christopher Kormanyos. +// Distributed under the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt +// or copy at https://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +namespace Mp = boost::multiprecision; +using namespace boost::multiprecision::literals; + +using uint384_t = Mp::number, Mp::et_off>; +using int512_t = Mp::number, Mp::et_off>; + +template +constexpr auto operator""_u384() -> uint384_t +{ + return operator""_cppui384 < TStr...>(); +} + +template +constexpr auto operator""_i512() -> int512_t +{ + return operator""_cppi512 < TStr...>(); +} + +auto main() -> int +{ + { + constexpr auto value { 0x00000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111_u384 }; + constexpr auto mask { 0x0000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_u384 }; + + constexpr auto masked { value & mask }; + + constexpr bool result_mask_is_ok { (value == masked) }; + constexpr bool result_size_is_ok { (value.backend().size() == masked.backend().size()) }; + + static_assert(result_mask_is_ok, "Error: unexpected value results in non-equality"); + static_assert(result_size_is_ok, "Error: unexpected size results in non-equality"); + + BOOST_TEST(result_mask_is_ok); + BOOST_TEST(result_size_is_ok); + } + + { + constexpr auto value { 0x00000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111_i512 }; + constexpr auto mask { 0x0000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_i512 }; + + constexpr auto masked { value & mask }; + + constexpr bool result_mask_is_ok { (value == masked) }; + constexpr bool result_size_is_ok { (value.backend().size() == masked.backend().size()) }; + + static_assert(result_mask_is_ok, "Error: unexpected value results in non-equality"); + static_assert(result_size_is_ok, "Error: unexpected size results in non-equality"); + + BOOST_TEST(result_mask_is_ok); + BOOST_TEST(result_size_is_ok); + } + + return boost::report_errors(); +}