From 259bdcccddecc244fd64a962281cad1a90a6336e Mon Sep 17 00:00:00 2001 From: Marco Ribeiro Date: Fri, 10 Apr 2026 15:50:11 -0300 Subject: [PATCH 1/2] Fix issue with temporaries when compiling constexpr expression templates with clang --- .../multiprecision/detail/number_base.hpp | 2 +- test/Jamfile.v2 | 1 + test/constexpr_test_cpp_int_8.cpp | 38 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/constexpr_test_cpp_int_8.cpp diff --git a/include/boost/multiprecision/detail/number_base.hpp b/include/boost/multiprecision/detail/number_base.hpp index 99017c92e..94990d8e6 100644 --- a/include/boost/multiprecision/detail/number_base.hpp +++ b/include/boost/multiprecision/detail/number_base.hpp @@ -457,7 +457,7 @@ struct expression_storage_base }; template -struct expression_storage : public expression_storage_base::value> +struct expression_storage : public expression_storage_base::value || std::is_empty::value> {}; template diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index fe0d61c59..d261c6f58 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1062,6 +1062,7 @@ test-suite misc : [ run constexpr_test_cpp_int_5.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : : no ] ] [ run constexpr_test_cpp_int_6.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : "msvc:-constexpr:steps10000000" clang:-fconstexpr-steps=268435456 : no ] [ check-target-builds ../config//has_constexpr_limits : -fconstexpr-ops-limit=268435456 ] ] [ run constexpr_test_cpp_int_7.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : "msvc:-constexpr:steps10000000" clang:-fconstexpr-steps=268435456 : no ] ] + [ run constexpr_test_cpp_int_8.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : : no ] ] [ compile test_nothrow_cpp_int.cpp ] [ compile test_nothrow_cpp_rational.cpp ] diff --git a/test/constexpr_test_cpp_int_8.cpp b/test/constexpr_test_cpp_int_8.cpp new file mode 100644 index 000000000..f7500cdf4 --- /dev/null +++ b/test/constexpr_test_cpp_int_8.cpp @@ -0,0 +1,38 @@ +// (C) Copyright Marco Ribeiro 2026. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include "constexpr_arithmetric_test.hpp" +#include "boost/multiprecision/cpp_int.hpp" +#include "test.hpp" + +#if !defined(BOOST_MP_NO_CONSTEXPR_DETECTION) && !defined(DISABLE_TESTS) + +int main() +{ + // ensure that + namespace mp = boost::multiprecision; + + using int512_et_off = mp::number, mp::et_off>; + + using int512_et_on = mp::number, mp::et_on>; + + static_assert(mp::abs(int512_et_off(-12345)) == 12345); + static_assert(mp::conj(int512_et_off(100)) == 100); + static_assert(mp::proj(int512_et_off(100)) == 100); + static_assert(mp::powm(int512_et_off(-5), 2, 7) == 4); + + static_assert(mp::abs(int512_et_on(-12345)) == 12345); + static_assert(mp::conj(int512_et_on(100)) == 100); + static_assert(mp::proj(int512_et_on(100)) == 100); + static_assert(mp::powm(int512_et_on(-5), 2, 7) == 4); +} +#else +int main() {} +#endif + From 3645c3046b64ca88060c77131a30cb716f8dc123 Mon Sep 17 00:00:00 2001 From: Marco Ribeiro Date: Fri, 10 Apr 2026 16:18:26 -0300 Subject: [PATCH 2/2] Remove incomplete comment at constexpr_test_cpp_int_8.cpp --- test/constexpr_test_cpp_int_8.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/constexpr_test_cpp_int_8.cpp b/test/constexpr_test_cpp_int_8.cpp index f7500cdf4..6c780bdae 100644 --- a/test/constexpr_test_cpp_int_8.cpp +++ b/test/constexpr_test_cpp_int_8.cpp @@ -11,7 +11,6 @@ int main() { - // ensure that namespace mp = boost::multiprecision; using int512_et_off = mp::number