From 6afd9e5d1004df0811a61925feeb125a0b1d4496 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Thu, 2 Nov 2023 16:26:38 +1100 Subject: [PATCH] ext/POSIX/t/math.t: don't assume the sign of NaN The test in Configure warns: /* Note that whether the sign bit is on or off * for NaN depends on the CPU/FPU, and possibly * can be affected by the build toolchain. but this test assumed that the default NaN was always positive, but this isn't the case with the Sun/Oracle workshop cc, whether on Oracle Linux or on Solaris. copysign() is however well defined for NaN, so we can modify the sign on NaN and test that with signbit(). Fixes #21533 --- ext/POSIX/t/math.t | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/POSIX/t/math.t b/ext/POSIX/t/math.t index f3a162a99bf9..95d7e47e7438 100644 --- a/ext/POSIX/t/math.t +++ b/ext/POSIX/t/math.t @@ -293,7 +293,8 @@ SKIP: { like(NAN, qr/^NaN/, "NAN is Perl's NaN"); cmp_ok(NAN, '!=', NAN, "NAN != NAN"); ok(!(NAN == NAN), "NAN == NAN"); - ok(!signbit(NAN), "signbit(NAN)"); + ok(!signbit(copysign(NAN, 1.0)), "signbit(copysign(NAN, 1.0)))"); + ok(signbit(copysign(NAN, -1.0)), "signbit(copysign(NAN, -1.0)))"); } done_testing();