Skip to content

Commit 460fde2

Browse files
authored
Merge pull request #1086 from cppalliance/1085
Fix build on POWER10
2 parents 0874cc8 + af807eb commit 460fde2

26 files changed

+189
-61
lines changed

include/boost/decimal/decimal128_t.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
223223
#endif
224224
BOOST_DECIMAL_CXX20_CONSTEXPR decimal128_t(Float val) noexcept;
225225

226+
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
227+
explicit constexpr decimal128_t(long double val) noexcept = delete;
228+
#endif
229+
226230
template <typename Float>
227231
BOOST_DECIMAL_CXX20_CONSTEXPR auto operator=(const Float& val) noexcept
228232
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_floating_point_v, Float, decimal128_t&);
@@ -282,7 +286,10 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
282286
// 3.2.6 Conversion to floating-point type
283287
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator float() const noexcept;
284288
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator double() const noexcept;
289+
290+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
285291
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator long double() const noexcept;
292+
#endif
286293

287294
#ifdef BOOST_DECIMAL_HAS_FLOAT16
288295
explicit constexpr operator std::float16_t() const noexcept;
@@ -943,10 +950,12 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal128_t::operator double() const noexcept
943950
return to_float<decimal128_t, double>(*this);
944951
}
945952

953+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
946954
BOOST_DECIMAL_CXX20_CONSTEXPR decimal128_t::operator long double() const noexcept
947955
{
948956
return to_float<decimal128_t, long double>(*this);
949957
}
958+
#endif
950959

951960
#ifdef BOOST_DECIMAL_HAS_FLOAT16
952961
constexpr decimal128_t::operator std::float16_t() const noexcept

include/boost/decimal/decimal32_t.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special
229229
#endif
230230
BOOST_DECIMAL_CXX20_CONSTEXPR decimal32_t(Float val) noexcept;
231231

232+
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
233+
explicit constexpr decimal32_t(long double val) noexcept = delete;
234+
#endif
235+
232236
template <typename Float>
233237
BOOST_DECIMAL_CXX20_CONSTEXPR auto operator=(const Float& val) noexcept
234238
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_floating_point_v, Float, decimal32_t&);
@@ -295,7 +299,10 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special
295299
// 3.2.6 Conversion to floating-point type
296300
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator float() const noexcept;
297301
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator double() const noexcept;
302+
303+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
298304
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator long double() const noexcept;
305+
#endif
299306

300307
#ifdef BOOST_DECIMAL_HAS_FLOAT16
301308
explicit constexpr operator std::float16_t() const noexcept;
@@ -1876,11 +1883,13 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal32_t::operator double() const noexcept
18761883
return to_float<decimal32_t, double>(*this);
18771884
}
18781885

1886+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
18791887
BOOST_DECIMAL_CXX20_CONSTEXPR decimal32_t::operator long double() const noexcept
18801888
{
18811889
// Double already has more range and precision than a decimal32_t will ever be able to provide
18821890
return static_cast<long double>(to_float<decimal32_t, double>(*this));
18831891
}
1892+
#endif
18841893

18851894
#ifdef BOOST_DECIMAL_HAS_FLOAT16
18861895
constexpr decimal32_t::operator std::float16_t() const noexcept

include/boost/decimal/decimal64_t.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
241241
#endif
242242
BOOST_DECIMAL_CXX20_CONSTEXPR decimal64_t(Float val) noexcept;
243243

244+
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
245+
explicit constexpr decimal64_t(long double val) noexcept = delete;
246+
#endif
247+
244248
template <typename Float>
245249
BOOST_DECIMAL_CXX20_CONSTEXPR auto operator=(const Float& val) noexcept
246250
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_floating_point_v, Float, decimal64_t&);
@@ -289,7 +293,10 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
289293
// 3.2.6 Conversion to a floating-point type
290294
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator float() const noexcept;
291295
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator double() const noexcept;
296+
297+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
292298
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator long double() const noexcept;
299+
#endif
293300

294301
#ifdef BOOST_DECIMAL_HAS_FLOAT16
295302
explicit constexpr operator std::float16_t() const noexcept;
@@ -856,10 +863,12 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal64_t::operator double() const noexcept
856863
return to_float<decimal64_t, double>(*this);
857864
}
858865

866+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
859867
BOOST_DECIMAL_CXX20_CONSTEXPR decimal64_t::operator long double() const noexcept
860868
{
861869
return to_float<decimal64_t, long double>(*this);
862870
}
871+
#endif
863872

864873
#ifdef BOOST_DECIMAL_HAS_FLOAT16
865874
constexpr decimal64_t::operator std::float16_t() const noexcept

include/boost/decimal/decimal_fast128_t.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final
180180
#endif
181181
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t(Float val) noexcept;
182182

183+
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
184+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t(long double val) noexcept = delete;
185+
#endif
186+
183187
friend constexpr auto direct_init_d128(significand_type significand, exponent_type exponent, bool sign) noexcept -> decimal_fast128_t;
184188

185189
// Classification functions
@@ -344,7 +348,10 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final
344348

345349
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator float() const noexcept;
346350
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator double() const noexcept;
351+
352+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
347353
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator long double() const noexcept;
354+
#endif
348355

349356
#ifdef BOOST_DECIMAL_HAS_FLOAT16
350357
explicit constexpr operator std::float16_t() const noexcept;
@@ -1237,10 +1244,12 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t::operator double() const noexcep
12371244
return to_float<decimal_fast128_t, double>(*this);
12381245
}
12391246

1247+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
12401248
BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t::operator long double() const noexcept
12411249
{
12421250
return to_float<decimal_fast128_t, long double>(*this);
12431251
}
1252+
#endif
12441253

12451254
#ifdef BOOST_DECIMAL_HAS_FLOAT16
12461255
constexpr decimal_fast128_t::operator std::float16_t() const noexcept

include/boost/decimal/decimal_fast32_t.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
161161
template <typename Float, std::enable_if_t<detail::is_floating_point_v<Float>, bool> = true>
162162
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast32_t(Float val) noexcept;
163163

164+
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
165+
explicit constexpr decimal_fast32_t(long double val) noexcept = delete;
166+
#endif
167+
164168
constexpr decimal_fast32_t(const decimal_fast32_t& val) noexcept = default;
165169
constexpr decimal_fast32_t(decimal_fast32_t&& val) noexcept = default;
166170
constexpr auto operator=(const decimal_fast32_t& val) noexcept -> decimal_fast32_t& = default;
@@ -336,7 +340,10 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
336340
// 3.2.6 Conversion to a floating-point type
337341
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator float() const noexcept;
338342
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator double() const noexcept;
343+
344+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
339345
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator long double() const noexcept;
346+
#endif
340347

341348
#ifdef BOOST_DECIMAL_HAS_FLOAT16
342349
explicit constexpr operator std::float16_t() const noexcept;
@@ -1285,11 +1292,13 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast32_t::operator double() const noexcept
12851292
return to_float<decimal_fast32_t, double>(*this);
12861293
}
12871294

1295+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
12881296
BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast32_t::operator long double() const noexcept
12891297
{
12901298
// The precision and range of double already exceeds what decimal_fast32_t can provide
12911299
return static_cast<long double>(to_float<decimal_fast32_t, double>(*this));
12921300
}
1301+
#endif
12931302

12941303
#ifdef BOOST_DECIMAL_HAS_FLOAT16
12951304
constexpr decimal_fast32_t::operator std::float16_t() const noexcept

include/boost/decimal/decimal_fast64_t.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final
191191
#endif
192192
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast64_t(Float val) noexcept;
193193

194+
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
195+
explicit constexpr decimal_fast64_t(long double val) noexcept = delete;
196+
#endif
197+
194198
friend constexpr auto direct_init_d64(decimal_fast64_t::significand_type significand, decimal_fast64_t::exponent_type exponent, bool sign) noexcept -> decimal_fast64_t;
195199

196200
// Classification functions
@@ -287,7 +291,9 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final
287291

288292
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator float() const noexcept;
289293
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator double() const noexcept;
294+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
290295
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator long double() const noexcept;
296+
#endif
291297

292298
#ifdef BOOST_DECIMAL_HAS_FLOAT16
293299
explicit constexpr operator std::float16_t() const noexcept;
@@ -849,10 +855,12 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast64_t::operator double() const noexcept
849855
return to_float<decimal_fast64_t, double>(*this);
850856
}
851857

858+
#ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
852859
BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast64_t::operator long double() const noexcept
853860
{
854861
return to_float<decimal_fast64_t, long double>(*this);
855862
}
863+
#endif
856864

857865
#ifdef BOOST_DECIMAL_HAS_FLOAT16
858866
constexpr decimal_fast64_t::operator std::float16_t() const noexcept

include/boost/decimal/detail/bit_layouts.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct IEEEl2bits
110110
#define BOOST_DECIMAL_LDBL_BITS 64
111111

112112
#else // Unsupported long double representation
113+
# define BOOST_DECIMAL_LDBL_BITS 0
113114
# define BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
114115
#endif
115116

include/boost/decimal/detail/ryu/ryu_generic_128.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,17 @@ BOOST_DECIMAL_CXX20_CONSTEXPR auto floating_point_to_fd128<long double>(long dou
346346
return generic_binary_to_decimal(bits, 112, 15, false);
347347
}
348348

349+
#elif BOOST_DECIMAL_LDBL_BITS == 0
350+
351+
template <>
352+
BOOST_DECIMAL_CXX20_CONSTEXPR auto floating_point_to_fd128<long double>(long double val) noexcept -> floating_decimal_128
353+
{
354+
BOOST_DECIMAL_ASSERT_MSG(1==0, "Unsupported configuration");
355+
356+
auto bits = bit_cast<unsigned_128_type>(val);
357+
return generic_binary_to_decimal(bits, 112, 15, false);
358+
}
359+
349360
#endif
350361

351362
#if defined(BOOST_DECIMAL_HAS_FLOAT128) && !defined(BOOST_DECIMAL_LDBL_IS_FLOAT128)

test/github_issue_426.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
#include <boost/decimal.hpp>
88
#include <boost/core/lightweight_test.hpp>
99

10-
#if defined(__GNUC__) && __GNUC__ >= 5 && __cplusplus > 202002L
10+
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
11+
12+
int main()
13+
{
14+
return 0;
15+
}
16+
17+
#elif defined(__GNUC__) && __GNUC__ >= 5 && __cplusplus > 202002L
1118

1219
#include <complex>
1320

test/roundtrip_decimal128.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ void test_roundtrip_conversion_float()
196196
}
197197
}
198198

199+
#if !defined(BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE)
200+
199201
template <>
200202
void test_roundtrip_conversion_float<long double>()
201203
{
@@ -247,6 +249,8 @@ void test_roundtrip_conversion_float<long double>()
247249
}
248250
}
249251

252+
#endif
253+
250254
template <typename T>
251255
void test_roundtrip_integer_stream()
252256
{
@@ -308,6 +312,8 @@ void test_roundtrip_float_stream()
308312
}
309313
}
310314

315+
#if !defined(BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE)
316+
311317
template <>
312318
void test_roundtrip_float_stream<long double>()
313319
{
@@ -340,6 +346,8 @@ void test_roundtrip_float_stream<long double>()
340346
}
341347
}
342348

349+
#endif
350+
343351
void test_roundtrip_conversion_decimal32_t()
344352
{
345353
std::mt19937_64 rng(42);
@@ -406,7 +414,7 @@ int main()
406414
test_roundtrip_float_stream<float>();
407415
test_roundtrip_float_stream<double>();
408416

409-
#if BOOST_DECIMAL_LDBL_BITS < 128
417+
#if BOOST_DECIMAL_LDBL_BITS < 128 && !defined(BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE)
410418
test_conversion_from_float<long double>();
411419
test_conversion_to_float<long double>();
412420
test_roundtrip_conversion_float<long double>();

0 commit comments

Comments
 (0)