From 893bb7e2129023c7d337d7dc1a19ddd441fc8c1b Mon Sep 17 00:00:00 2001 From: chenhaixiang Date: Thu, 8 Dec 2022 19:49:13 +0800 Subject: [PATCH] random test Add missing includes and fix overflow Signed-off-by: chenhaixiang3@huawei.com --- ....78-random-test-Add-missing-includes.patch | 38 +++++++++++++++++++ ...ision_float_test.cpp-to-not-overflow.patch | 31 +++++++++++++++ ...ision_int_test.cpp-to-not-accidental.patch | 35 +++++++++++++++++ boost.spec | 8 +++- 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 boost-1.78-random-test-Add-missing-includes.patch create mode 100644 boost-1.80-random-Update-multiprecision_float_test.cpp-to-not-overflow.patch create mode 100644 boost-1.80-random-Update-multiprecision_int_test.cpp-to-not-accidental.patch diff --git a/boost-1.78-random-test-Add-missing-includes.patch b/boost-1.78-random-test-Add-missing-includes.patch new file mode 100644 index 0000000..72bf357 --- /dev/null +++ b/boost-1.78-random-test-Add-missing-includes.patch @@ -0,0 +1,38 @@ +From c3ada7a1b2b54f4b27585f72308a76984f8489b4 Mon Sep 17 00:00:00 2001 +From: jzmaddock +Date: Tue, 16 Mar 2021 10:47:16 +0000 +Subject: [PATCH] Add missing #includes. + +Reference:https://github.com/boostorg/random/pull/88/commits/c3ada7a1b2b54f4b27585f72308a76984f8489b4 +--- + test/multiprecision_float_test.cpp | 1 + + test/multiprecision_int_test.cpp | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/libs/random/test/multiprecision_float_test.cpp b/libs/random/test/multiprecision_float_test.cpp +index 904c59d..bc2a936 100644 +--- a/libs/random/test/multiprecision_float_test.cpp ++++ b/libs/random/test/multiprecision_float_test.cpp +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + + +diff --git a/libs/random/test/multiprecision_int_test.cpp b/libs/random/test/multiprecision_int_test.cpp +index 577e52a..41ec229 100644 +--- a/libs/random/test/multiprecision_int_test.cpp ++++ b/libs/random/test/multiprecision_int_test.cpp +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + #include + + typedef boost::mpl::list < +-- +2.33.0 + diff --git a/boost-1.80-random-Update-multiprecision_float_test.cpp-to-not-overflow.patch b/boost-1.80-random-Update-multiprecision_float_test.cpp-to-not-overflow.patch new file mode 100644 index 0000000..df084f4 --- /dev/null +++ b/boost-1.80-random-Update-multiprecision_float_test.cpp-to-not-overflow.patch @@ -0,0 +1,31 @@ +From 4239d93dad32a11e4c3829050f8070d456266133 Mon Sep 17 00:00:00 2001 +From: jzmaddock +Date: Wed, 1 Jun 2022 19:35:36 +0100 +Subject: [PATCH] Update multiprecision_float_test.cpp to not overflow type + double. Previously the max value for uint1024_t could just squeeze into a + double because truncation occurred during the conversion, now that cpp_int + performs correctly rounded conversions, overflow occurs, and the computation + fails. Changed the problem distribution to use a multiprecision weight type, + rather than double. + +Reference:https://github.com/boostorg/random/pull/88/commits/4239d93dad32a11e4c3829050f8070d456266133 +--- + libs/random/test/multiprecision_float_test.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libs/random/test/multiprecision_float_test.cpp b/libs/random/test/multiprecision_float_test.cpp +index bc2a936..2b53483 100644 +--- a/libs/random/test/multiprecision_float_test.cpp ++++ b/libs/random/test/multiprecision_float_test.cpp +@@ -77,7 +77,7 @@ typedef boost::mpl::list < + boost::random::lognormal_distribution, + boost::random::normal_distribution, + #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS +- boost::random::piecewise_constant_distribution, ++ boost::random::piecewise_constant_distribution, + boost::random::piecewise_linear_distribution, + #endif + boost::random::student_t_distribution, +-- +2.33.0 + diff --git a/boost-1.80-random-Update-multiprecision_int_test.cpp-to-not-accidental.patch b/boost-1.80-random-Update-multiprecision_int_test.cpp-to-not-accidental.patch new file mode 100644 index 0000000..5743c51 --- /dev/null +++ b/boost-1.80-random-Update-multiprecision_int_test.cpp-to-not-accidental.patch @@ -0,0 +1,35 @@ +From 7561690135c67ecf88c2133bad7680ebd2665c36 Mon Sep 17 00:00:00 2001 +From: jzmaddock +Date: Wed, 1 Jun 2022 19:32:55 +0100 +Subject: [PATCH] Update multiprecision_int_test.cpp to not accidentality + overflow type double. Multiprecision now performs correct rounding when + converting to double - previously the max value for uint1024_t would just fit + in a double if it was truncated. But now that it's correctly rounded it + overflows and breaks the calculation. + +Reference:https://github.com/boostorg/random/pull/88/commits/7561690135c67ecf88c2133bad7680ebd2665c36 +--- + libs/random/test/multiprecision_int_test.cpp | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/libs/random/test/multiprecision_int_test.cpp b/libs/random/test/multiprecision_int_test.cpp +index 41ec229..a861cca 100644 +--- a/libs/random/test/multiprecision_int_test.cpp ++++ b/libs/random/test/multiprecision_int_test.cpp +@@ -215,8 +215,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(discrete_distributions, distribution_type, other_d + distribution_type d2; + ss >> d2; + BOOST_CHECK(d == d2); +- +- boost::random::independent_bits_engine::digits, boost::multiprecision::uint1024_t > big_random; ++ // ++ // The number of digits in the independent_bits_engine must be low enough that we don't overflow ++ // when converting to a double (see other_distributions declared above). ++ // ++ boost::random::independent_bits_engine::digits - 2, boost::multiprecision::uint1024_t > big_random; + for(unsigned i = 0; i < 200; ++i) + { + result_type r = d(big_random); +-- +2.33.0 + diff --git a/boost.spec b/boost.spec index ab67f94..cd23ea7 100644 --- a/boost.spec +++ b/boost.spec @@ -2,7 +2,7 @@ Name: boost Version: 1.80.0 -Release: 5 +Release: 6 Summary: The free peer-reviewed portable C++ source libraries License: BSL-1.0 URL: http://www.boost.org @@ -14,6 +14,9 @@ Source0: https://boostorg.jfrog.io/ui/native/main/release/%{version}/sour Patch0: boost-1.78-python-Update-call_method-hpp.patch # https://github.com/ned14/outcome/commit/66ebdd4e86ab593c8723ee69f6654260de19775e Patch1: boost-1.80-outcome-Stop-Boost-regression-tests-complaining-about-no-test-tree.patch +Patch2: boost-1.78-random-test-Add-missing-includes.patch +Patch3: boost-1.80-random-Update-multiprecision_float_test.cpp-to-not-overflow.patch +Patch4: boost-1.80-random-Update-multiprecision_int_test.cpp-to-not-accidental.patch Patch9000: boost-1.80-config-skip-gcc-known-issue.patch Requires: %{name}-atomic%{?_isa} = %{version}-%{release} @@ -430,6 +433,9 @@ find libs -name example -exec cp {} boost-example --parents -r \; %{_libdir}/*.a %changelog +* Thu Dec 08 2022 chenhaixiang - 1.80.0-6 +- random test Add missing includes and fix overflow + * Thu Dec 08 2022 Liu Zixian - 1.80.0-5 - statechart: avoid undefined behavior -- Gitee