Skip to content

Commit bf26f4b

Browse files
committed
handle case: sizeof(double) == sizeof(long double)
1 parent 862c745 commit bf26f4b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libcxx/include/__math/hypot.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,14 @@ std::array<__hypot_factors<_Real>, 2> __create_factors() {
7272
__overflow = __hypot_factors<_Real>{0x1.0p510, 0x1.0p-600, 0x1.0p+600};
7373
} else { // long double
7474
static_assert(std::is_same_v<_Real, long double>);
75-
static_assert(-16'381 == std::numeric_limits<_Real>::min_exponent);
76-
static_assert(+16'384 == std::numeric_limits<_Real>::max_exponent);
77-
__underflow = __hypot_factors<_Real>{0x1.0p-8'190l, 0x1.0p9'000l, 0x1.0p-9'000l};
78-
__overflow = __hypot_factors<_Real>{0x1.0p8'190l, 0x1.0p-9'000l, 0x1.0p+9'000l};
75+
if constexpr (sizeof(_Real) == sizeof(double))
76+
return static_cast<std::array<__hypot_factors<_Real>, 2>>(__create_factors<double>());
77+
else {
78+
static_assert(-16'381 == std::numeric_limits<_Real>::min_exponent);
79+
static_assert(+16'384 == std::numeric_limits<_Real>::max_exponent);
80+
__underflow = __hypot_factors<_Real>{0x1.0p-8'190l, 0x1.0p9'000l, 0x1.0p-9'000l};
81+
__overflow = __hypot_factors<_Real>{0x1.0p8'190l, 0x1.0p-9'000l, 0x1.0p+9'000l};
82+
}
7983
}
8084
return {__underflow, __overflow};
8185
}

0 commit comments

Comments
 (0)