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.
The same issue applies for remainder (1.0, 0.0), which likewise needs logic to raise the INVALID exception rather than just quietly returning a NaN.
commit a1cbf437a53b24f2ff1f6af42028b607f6aa279d Author: Thomas Schwinge <thomas@codesourcery.com> Date: Thu Apr 4 17:35:12 2013 +0200 [BZ #14686, #15336] Fix standard compliance. Don't use hard-coded qNaN values. Additional tests in <http://news.gmane.org/find-root.php?message_id=%3C87r4iqxq1n.fsf%40schwinge.name%3E> not yet committed.