[Bug 272539] cospi, sinpi and tanpi incorrectly test for NaN and Infinity

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 17 Jul 2023 02:24:43 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272539

            Bug ID: 272539
           Summary: cospi, sinpi and tanpi incorrectly test for NaN and
                    Infinity
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: Paul.Green@stratus.com

The current versions of lib/msun/src/s_cospi.c, s_sinpi.c and s_tanpi.c all
exhibit the same defect. After checking for various numeric ranges, they check
to see whether the input argument is a NaN or an Infinity. However, the code
uses a value of 0x7f80000 instead of the correct value of 0x7ff00000. See line
141 of s_cospi.c, line 158 of s_sinpi.c, and line 166 of s_tanpi.c. 

I strongly recommend that s_cospi.c and s_sinpi.c have a comment added just
before this line to say that the code is testing for infinity or nan. Such a
comment already exists in s_tanpi.c.

If you review s_cospif.c, s_sinpif.c, and s_tanpif.c, you will see that the
equivalent statements in these functions are accurate and have appropriate
source comments.

Cross-ref: PR 218514, which added these functions and is still open for reasons
that are unclear.

I have run this issue past the author of these functions and he agrees with my
analysis. 

The impact of these defects is to flag some valid input values as invalid and
raise a pole error (divide by zero).

-- 
You are receiving this mail because:
You are the assignee for the bug.