This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/15797] New: Incorrect fdim handling of infinities


http://sourceware.org/bugzilla/show_bug.cgi?id=15797

            Bug ID: 15797
           Summary: Incorrect fdim handling of infinities
           Product: glibc
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: jsm28 at gcc dot gnu.org

The generic fdim implementation does:

  if (clsx == FP_NAN || clsy == FP_NAN
      || (y < 0 && clsx == FP_INFINITE && clsy == FP_INFINITE))
    /* Raise invalid flag.  */
    return x - y;

I'm not sure of the purpose of the FP_INFINITE checks here, but the only case
they help with is fdim (Inf, -Inf), avoiding an incorrect errno setting.  For
fdim (-Inf, -Inf), the infinities are wrongly subtracted resulting in a NaN
return with "invalid" exception, when the correct result for equal infinite
arguments is 0 (+0, independent of rounding mode).  For other cases of fdim
where an argument is an infinity and the expected result is an exact (positive)
infinity, errno will be wrongly set to ERANGE because the result is wrongly
considered to overflow.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]