Skip to content

Commit 38326a7

Browse files
authored
Merge pull request #658 from boostorg/develop
Merge to master for 1.88
2 parents 7e847d4 + 83d5844 commit 38326a7

File tree

6 files changed

+109
-11
lines changed

6 files changed

+109
-11
lines changed

.github/workflows/codecov.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ env:
2828
B2_LINK: shared,static
2929
LCOV_BRANCH_COVERAGE: 0
3030
CODECOV_NAME: Github Actions
31-
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
3231

3332
jobs:
3433
posix:
@@ -94,21 +93,21 @@ jobs:
9493
fi
9594
git config --global pack.threads 0
9695
97-
- uses: actions/checkout@v3
96+
- uses: actions/checkout@v4
9897
with:
9998
# For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary'
10099
fetch-depth: ${{ matrix.coverage && '0' || '1' }}
101100

102101
- name: Cache ccache
103-
uses: actions/cache@v3
102+
uses: actions/cache@v4
104103
if: env.B2_USE_CCACHE
105104
with:
106105
path: ~/.ccache
107106
key: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-${{github.sha}}
108107
restore-keys: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-
109108

110109
- name: Fetch Boost.CI
111-
uses: actions/checkout@v3
110+
uses: actions/checkout@v4
112111
with:
113112
repository: boostorg/boost-ci
114113
ref: master

include/boost/multiprecision/cpp_bin_float.hpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class cpp_bin_float
346346
m_sign = false;
347347
m_exponent = 0;
348348

349-
constexpr std::ptrdiff_t bits = sizeof(int) * CHAR_BIT - 1 < MaxExponent - 1 ? sizeof(int) * CHAR_BIT - 1 : 3;
349+
constexpr std::ptrdiff_t bits = static_cast<Exponent>(sizeof(int) * CHAR_BIT - 1) < MaxExponent - 1 ? sizeof(int) * CHAR_BIT - 1 : 3;
350350
int e;
351351
f = frexpq(f, &e);
352352
while (f)
@@ -416,6 +416,8 @@ class cpp_bin_float
416416
m_sign = (f < 0);
417417
m_exponent = exponent_infinity;
418418
return *this;
419+
default:
420+
break;
419421
}
420422
if (f < 0)
421423
{
@@ -494,6 +496,8 @@ class cpp_bin_float
494496
m_sign = eval_get_sign(f) < 0;
495497
m_exponent = exponent_infinity;
496498
return *this;
499+
default:
500+
break;
497501
}
498502
if (eval_get_sign(f) < 0)
499503
{
@@ -805,6 +809,8 @@ inline void do_eval_add(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Mi
805809
case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
806810
res = a;
807811
return; // result is still a NaN.
812+
default:
813+
break;
808814
}
809815
switch (b.exponent())
810816
{
@@ -819,6 +825,8 @@ inline void do_eval_add(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Mi
819825
case BinFloat3::exponent_nan:
820826
res = b;
821827
return; // result is a NaN.
828+
default:
829+
break;
822830
}
823831

824832
static_assert((std::numeric_limits<exponent_type>::max)() - cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent, "Exponent range check failed");
@@ -878,6 +886,8 @@ inline void do_eval_subtract(BinFloat1& res, const BinFloat2& a, const BinFloat3
878886
case BinFloat2::exponent_nan:
879887
res = a;
880888
return; // result is still a NaN.
889+
default:
890+
break;
881891
}
882892
switch (b.exponent())
883893
{
@@ -892,6 +902,8 @@ inline void do_eval_subtract(BinFloat1& res, const BinFloat2& a, const BinFloat3
892902
case BinFloat3::exponent_nan:
893903
res = b;
894904
return; // result is still a NaN.
905+
default:
906+
break;
895907
}
896908

897909
bool s = a.sign();
@@ -1043,6 +1055,8 @@ inline void eval_multiply(cpp_bin_float<Digits, DigitBase, Allocator, Exponent,
10431055
case cpp_bin_float<Digits, DigitBase, Allocator2, Exponent2, MinE2, MaxE2>::exponent_nan:
10441056
res = a;
10451057
return;
1058+
default:
1059+
break;
10461060
}
10471061
if (b.exponent() > cpp_bin_float<Digits, DigitBase, Allocator3, Exponent3, MinE3, MaxE3>::max_exponent)
10481062
{
@@ -1119,6 +1133,8 @@ inline typename std::enable_if<boost::multiprecision::detail::is_unsigned<U>::va
11191133
case cpp_bin_float<Digits, DigitBase, Allocator2, Exponent2, MinE2, MaxE2>::exponent_nan:
11201134
res = a;
11211135
return;
1136+
default:
1137+
break;
11221138
}
11231139

11241140
typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type dt;
@@ -1183,6 +1199,8 @@ inline void eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Mi
11831199
case cpp_bin_float<Digits, DigitBase, Allocator3, Exponent3, MinE3, MaxE3>::exponent_nan:
11841200
res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
11851201
return;
1202+
default:
1203+
break;
11861204
}
11871205
bool s = u.sign() != v.sign();
11881206
res = u;
@@ -1197,6 +1215,8 @@ inline void eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Mi
11971215
case cpp_bin_float<Digits, DigitBase, Allocator3, Exponent3, MinE3, MaxE3>::exponent_nan:
11981216
res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
11991217
return;
1218+
default:
1219+
break;
12001220
}
12011221
bool s = u.sign() != v.sign();
12021222
res = u;
@@ -1206,6 +1226,8 @@ inline void eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Mi
12061226
case cpp_bin_float<Digits, DigitBase, Allocator2, Exponent2, MinE2, MaxE2>::exponent_nan:
12071227
res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
12081228
return;
1229+
default:
1230+
break;
12091231
}
12101232
switch (v.exponent())
12111233
{
@@ -1224,6 +1246,8 @@ inline void eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Mi
12241246
case cpp_bin_float<Digits, DigitBase, Allocator3, Exponent3, MinE3, MaxE3>::exponent_nan:
12251247
res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
12261248
return;
1249+
default:
1250+
break;
12271251
}
12281252

12291253
// We can scale u and v so that both are integers, then perform integer
@@ -1368,6 +1392,8 @@ inline typename std::enable_if<boost::multiprecision::detail::is_unsigned<U>::va
13681392
case cpp_bin_float<Digits, DigitBase, Allocator2, Exponent2, MinE2, MaxE2>::exponent_nan:
13691393
res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
13701394
return;
1395+
default:
1396+
break;
13711397
}
13721398
if (v == 0)
13731399
{
@@ -1514,6 +1540,8 @@ inline void convert_to_signed_int(I* res, const cpp_bin_float<Digits, DigitBase,
15141540
if (arg.sign())
15151541
*res = -*res;
15161542
return;
1543+
default:
1544+
break;
15171545
}
15181546
using shift_type = typename std::conditional<sizeof(typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type) < sizeof(int), int, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type>::type;
15191547
typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::rep_type man(arg.bits());
@@ -1589,6 +1617,8 @@ inline void convert_to_unsigned_int(I* res, const cpp_bin_float<Digits, DigitBas
15891617
case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
15901618
*res = max_val;
15911619
return;
1620+
default:
1621+
break;
15921622
}
15931623
typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::rep_type man(arg.bits());
15941624
using shift_type = typename std::conditional<sizeof(typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type) < sizeof(int), int, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type>::type;
@@ -1669,6 +1699,8 @@ inline typename std::enable_if<std::is_floating_point<Float>::value>::type eval_
16691699
if (original_arg.sign())
16701700
*res = -*res;
16711701
return;
1702+
default:
1703+
break;
16721704
}
16731705
//
16741706
// Check for super large exponent that must be converted to infinity:
@@ -1740,6 +1772,8 @@ inline void eval_frexp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Min
17401772
*e = 0;
17411773
res = arg;
17421774
return;
1775+
default:
1776+
break;
17431777
}
17441778
res = arg;
17451779
*e = arg.exponent() + 1;
@@ -1768,6 +1802,8 @@ inline void eval_ldexp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Min
17681802
case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
17691803
res = arg;
17701804
return;
1805+
default:
1806+
break;
17711807
}
17721808
if ((e > 0) && (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent - e < arg.exponent()))
17731809
{
@@ -1853,6 +1889,8 @@ inline int eval_fpclassify(const cpp_bin_float<Digits, DigitBase, Allocator, Exp
18531889
return FP_INFINITE;
18541890
case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
18551891
return FP_NAN;
1892+
default:
1893+
break;
18561894
}
18571895
return FP_NORMAL;
18581896
}
@@ -1880,6 +1918,8 @@ inline void eval_sqrt(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE
18801918
else
18811919
res = arg;
18821920
return;
1921+
default:
1922+
break;
18831923
}
18841924
if (arg.sign())
18851925
{
@@ -1921,6 +1961,8 @@ inline void eval_floor(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, Min
19211961
case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
19221962
res = arg;
19231963
return;
1964+
default:
1965+
break;
19241966
}
19251967
using shift_type = typename std::conditional<sizeof(typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type) < sizeof(int), int, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type>::type;
19261968
shift_type shift =
@@ -1969,6 +2011,8 @@ inline void eval_ceil(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE
19692011
case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
19702012
res = arg;
19712013
return;
2014+
default:
2015+
break;
19722016
}
19732017
using shift_type = typename std::conditional<sizeof(typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type) < sizeof(int), int, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type>::type;
19742018
shift_type shift = (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - arg.exponent() - 1;

include/boost/multiprecision/cpp_bin_float/io.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,8 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s
687687
case exponent_infinity:
688688
s = sign() ? "-inf" : f & std::ios_base::showpos ? "+inf" : "inf";
689689
break;
690+
default:
691+
break;
690692
}
691693
}
692694
return s;

include/boost/multiprecision/detail/default_ops.hpp

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fmod(T& result, const T& a, const T& b
12781278
result = std::numeric_limits<number<T> >::quiet_NaN().backend();
12791279
errno = EDOM;
12801280
return;
1281+
default:
1282+
break;
12811283
}
12821284
switch (eval_fpclassify(b))
12831285
{
@@ -1286,6 +1288,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fmod(T& result, const T& a, const T& b
12861288
result = std::numeric_limits<number<T> >::quiet_NaN().backend();
12871289
errno = EDOM;
12881290
return;
1291+
default:
1292+
break;
12891293
}
12901294
T n;
12911295
eval_divide(result, a, b);
@@ -1411,6 +1415,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fdim(T& result, const T& a, const T& b
14111415
case FP_INFINITE:
14121416
result = zero;
14131417
return;
1418+
default:
1419+
break;
14141420
}
14151421
switch (eval_fpclassify(a))
14161422
{
@@ -1420,6 +1426,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fdim(T& result, const T& a, const T& b
14201426
case FP_INFINITE:
14211427
result = a;
14221428
return;
1429+
default:
1430+
break;
14231431
}
14241432
if (eval_gt(a, b))
14251433
{
@@ -1442,6 +1450,8 @@ inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::d
14421450
case FP_INFINITE:
14431451
result = zero;
14441452
return;
1453+
default:
1454+
break;
14451455
}
14461456
switch (eval_fpclassify(a))
14471457
{
@@ -1451,6 +1461,8 @@ inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::d
14511461
case FP_INFINITE:
14521462
result = a;
14531463
return;
1464+
default:
1465+
break;
14541466
}
14551467
if (eval_gt(a, canonical_b))
14561468
{
@@ -1473,6 +1485,8 @@ inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::d
14731485
case FP_INFINITE:
14741486
result = zero;
14751487
return;
1488+
default:
1489+
break;
14761490
}
14771491
switch (BOOST_MP_FPCLASSIFY(a))
14781492
{
@@ -1482,6 +1496,8 @@ inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::d
14821496
case FP_INFINITE:
14831497
result = std::numeric_limits<number<T> >::infinity().backend();
14841498
return;
1499+
default:
1500+
break;
14851501
}
14861502
if (eval_gt(canonical_a, b))
14871503
{
@@ -1504,6 +1520,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_trunc(T& result, const T& a)
15041520
case FP_INFINITE:
15051521
result = a;
15061522
return;
1523+
default:
1524+
break;
15071525
}
15081526
if (eval_get_sign(a) < 0)
15091527
eval_ceil(result, a);
@@ -1920,6 +1938,8 @@ inline BOOST_MP_CXX14_CONSTEXPR typename B::exponent_type eval_ilogb(const B& va
19201938
return (std::numeric_limits<typename B::exponent_type>::max)();
19211939
case FP_ZERO:
19221940
return (std::numeric_limits<typename B::exponent_type>::min)();
1941+
default:
1942+
break;
19231943
}
19241944
B result;
19251945
eval_frexp(result, val, &e);
@@ -1945,6 +1965,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_logb(B& result, const B& val)
19451965
if (eval_signbit(val))
19461966
result.negate();
19471967
return;
1968+
default:
1969+
break;
19481970
}
19491971
using max_t = typename std::conditional<std::is_same<std::intmax_t, long>::value, long long, std::intmax_t>::type;
19501972
result = static_cast<max_t>(eval_ilogb(val));
@@ -2338,21 +2360,21 @@ template <class T, expression_template_option ExpressionTemplates>
23382360
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<T>::value == number_kind_complex, component_type<number<T, ExpressionTemplates>>>::type::type
23392361
abs(const number<T, ExpressionTemplates>& v)
23402362
{
2341-
return std::move(boost::math::hypot(real(v), imag(v)));
2363+
return boost::math::hypot(real(v), imag(v));
23422364
}
23432365
template <class tag, class A1, class A2, class A3, class A4>
23442366
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_complex, component_type<typename detail::expression<tag, A1, A2, A3, A4>::result_type>>::type::type
23452367
abs(const detail::expression<tag, A1, A2, A3, A4>& v)
23462368
{
23472369
using number_type = typename detail::expression<tag, A1, A2, A3, A4>::result_type;
2348-
return std::move(abs(static_cast<number_type>(v)));
2370+
return abs(static_cast<number_type>(v));
23492371
}
23502372

23512373
template <class T, expression_template_option ExpressionTemplates>
23522374
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<T>::value == number_kind_complex, typename scalar_result_from_possible_complex<number<T, ExpressionTemplates> >::type>::type
23532375
arg(const number<T, ExpressionTemplates>& v)
23542376
{
2355-
return std::move(atan2(imag(v), real(v)));
2377+
return atan2(imag(v), real(v));
23562378
}
23572379
template <class T, expression_template_option ExpressionTemplates>
23582380
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<T>::value == number_kind_floating_point, typename scalar_result_from_possible_complex<number<T, ExpressionTemplates> >::type>::type
@@ -2365,7 +2387,7 @@ inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<typename
23652387
arg(const detail::expression<tag, A1, A2, A3, A4>& v)
23662388
{
23672389
using number_type = typename detail::expression<tag, A1, A2, A3, A4>::result_type;
2368-
return std::move(arg(static_cast<number_type>(v)));
2390+
return arg(static_cast<number_type>(v));
23692391
}
23702392
#endif // BOOST_MP_MATH_AVAILABLE
23712393

@@ -2374,7 +2396,7 @@ inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<T>::valu
23742396
norm(const number<T, ExpressionTemplates>& v)
23752397
{
23762398
typename component_type<number<T, ExpressionTemplates> >::type a(real(v)), b(imag(v));
2377-
return std::move(a * a + b * b);
2399+
return a * a + b * b;
23782400
}
23792401
template <class T, expression_template_option ExpressionTemplates>
23802402
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<T>::value != number_kind_complex, typename scalar_result_from_possible_complex<number<T, ExpressionTemplates> >::type>::type
@@ -2387,7 +2409,7 @@ inline BOOST_MP_CXX14_CONSTEXPR typename scalar_result_from_possible_complex<typ
23872409
norm(const detail::expression<tag, A1, A2, A3, A4>& v)
23882410
{
23892411
using number_type = typename detail::expression<tag, A1, A2, A3, A4>::result_type;
2390-
return std::move(norm(static_cast<number_type>(v)));
2412+
return norm(static_cast<number_type>(v));
23912413
}
23922414

23932415
template <class Backend, expression_template_option ExpressionTemplates>

0 commit comments

Comments
 (0)