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/14686] New: remainder sometimes fails to raise INVALID exception with -lieee


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

             Bug #: 14686
           Summary: remainder sometimes fails to raise INVALID exception
                    with -lieee
           Product: glibc
           Version: 2.16
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jsm28@gcc.gnu.org
    Classification: Unclassified


The following test, on x86_64, with -fno-builtin -lieee, shows the remainder
function failing to raise the INVALID exception.

#include <errno.h>
#include <fenv.h>
#include <math.h>
#include <stdio.h>
#include <float.h>
#include <complex.h>

volatile double a = INFINITY, b = 2.0;

int
main (void)
{
  feclearexcept (FE_ALL_EXCEPT);
  errno = 0;
  volatile double r = remainder (a, b);
  if (fetestexcept (FE_DIVBYZERO))
    printf ("DIVBYZERO ");
  if (fetestexcept (FE_INEXACT))
    printf ("INEXACT ");
  if (fetestexcept (FE_INVALID))
    printf ("INVALID ");
  if (fetestexcept (FE_OVERFLOW))
    printf ("OVERFLOW ");
  if (fetestexcept (FE_UNDERFLOW))
    printf ("UNDERFLOW ");
  printf ("%.18g %m\n", r);
  return 0;
}

The problem is the code in dbl-64/e_remainder.c

      if (kx == 0x7ff00000 && u.i[LOW_HALF] == 0 && y == 1.0)
        return x / x;

which acts only when y == 1.0, but should act for any non-NaN value of y
(finite or infinite).  Any remainder (non-NaN, 0) or remainder (Inf, non-NaN)
should return NaN and raise the INVALID exception.  In the absence of -lieee,
this issue is masked by the w_remainder.c wrapper.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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]