]> sourceware.org Git - glibc.git/commitdiff
Fix csin, csinh, ccos, ccosh missing underflows (bug 15405).
authorJoseph Myers <joseph@codesourcery.com>
Fri, 26 Apr 2013 19:25:19 +0000 (19:25 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Fri, 26 Apr 2013 19:25:19 +0000 (19:25 +0000)
12 files changed:
ChangeLog
NEWS
math/libm-test.inc
math/s_ccosh.c
math/s_ccoshf.c
math/s_ccoshl.c
math/s_csin.c
math/s_csinf.c
math/s_csinh.c
math/s_csinhf.c
math/s_csinhl.c
math/s_csinl.c

index 2900e14a64683c834b343ee18af7f1ac412d5c82..1996e6c04a00b866a252fe2cc4af38276a7f6ec4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-04-26  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #15405]
+       * math/s_ccosh.c (__ccosh): Ensure underflow exception occurs for
+       underflowed result.
+       * math/s_ccoshf.c (__ccoshf): Likewise.
+       * math/s_ccoshl.c (__ccoshl): Likewise.
+       * math/s_csin.c (__csin): Likewise.
+       * math/s_csinf.c (__csinf): Likewise.
+       * math/s_csinh.c (__csinh): Likewise.
+       * math/s_csinhf.c (__csinhf): Likewise.
+       * math/s_csinhl.c (__csinhl): Likewise.
+       * math/s_csinl.c (__csinl): Likewise.
+       * math/libm-test.inc (ccos_test): Add more tests.
+       (ccosh_test): Likewise.
+       (csin_test): Likewise.
+       (csinh_test): Likewise.
+
 2013-04-26  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
        * sysdeps/powerpc/power5/fpu/s_modf.c: Moved to ...
diff --git a/NEWS b/NEWS
index c5b57a8c2ee93f49ee60f7b4005080de808789ac..f986862b97622f8c3b880c642cf0da7e37c70d35 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,7 +14,7 @@ Version 2.18
   14812, 14888, 14920, 14964, 14981, 14982, 14985, 14994, 14996, 15003,
   15006, 15020, 15023, 15036, 15054, 15055, 15062, 15078, 15160, 15214,
   15232, 15234, 15283, 15285, 15287, 15304, 15305, 15307, 15309, 15327,
-  15330, 15335, 15336, 15337, 15342, 15346, 15361, 15366, 15394.
+  15330, 15335, 15336, 15337, 15342, 15346, 15361, 15366, 15394, 15405.
 
 * CVE-2013-0242 Buffer overrun in regexp matcher has been fixed (Bugzilla
   #15078).
index eb9fa710cd87836179b7d6d2dfb0e40970bd143b..a3d773153128135c486c1977303761a34fe756b9 100644 (file)
@@ -4570,6 +4570,9 @@ ccos_test (void)
   TEST_c_c (ccos, 0x1p-16434L, 22730, plus_infty, -1.217853148905605987081057582351152052687e4924L, OVERFLOW_EXCEPTION);
 #endif
 
+  TEST_c_c (ccos, min_subnorm_value * 0x1p120, 0x1p-120, 1.0, -min_subnorm_value, UNDERFLOW_EXCEPTION);
+  TEST_c_c (ccos, 0x1p-120, min_subnorm_value * 0x1p120, 1.0, -min_subnorm_value, UNDERFLOW_EXCEPTION);
+
   END (ccos, complex);
 }
 
@@ -4670,6 +4673,9 @@ ccosh_test (void)
   TEST_c_c (ccosh, 22730, 0x1p-16434L, plus_infty, 1.217853148905605987081057582351152052687e4924L, OVERFLOW_EXCEPTION);
 #endif
 
+  TEST_c_c (ccosh, min_subnorm_value * 0x1p120, 0x1p-120, 1.0, min_subnorm_value, UNDERFLOW_EXCEPTION);
+  TEST_c_c (ccosh, 0x1p-120, min_subnorm_value * 0x1p120, 1.0, min_subnorm_value, UNDERFLOW_EXCEPTION);
+
   END (ccosh, complex);
 }
 
@@ -5898,6 +5904,9 @@ csin_test (void)
   TEST_c_c (csin, 0x1p-16434L, 22730, 1.217853148905605987081057582351152052687e4924L, plus_infty, OVERFLOW_EXCEPTION);
 #endif
 
+  TEST_c_c (csin, min_subnorm_value, min_value, min_subnorm_value, min_value, UNDERFLOW_EXCEPTION);
+  TEST_c_c (csin, min_value, min_subnorm_value, min_value, min_subnorm_value, UNDERFLOW_EXCEPTION);
+
   END (csin, complex);
 }
 
@@ -5997,6 +6006,9 @@ csinh_test (void)
   TEST_c_c (csinh, 22730, 0x1p-16434L, plus_infty, 1.217853148905605987081057582351152052687e4924L, OVERFLOW_EXCEPTION);
 #endif
 
+  TEST_c_c (csinh, min_subnorm_value, min_value, min_subnorm_value, min_value, UNDERFLOW_EXCEPTION);
+  TEST_c_c (csinh, min_value, min_subnorm_value, min_value, min_subnorm_value, UNDERFLOW_EXCEPTION);
+
   END (csinh, complex);
 }
 
index 2c05b63de471d83c046af7b14f2e375224a1cafa..05b146ecbf63f10d8b2c57396ad6c58abe40e454 100644 (file)
@@ -82,6 +82,19 @@ __ccosh (__complex__ double x)
              __real__ retval = __ieee754_cosh (__real__ x) * cosix;
              __imag__ retval = __ieee754_sinh (__real__ x) * sinix;
            }
+
+         if (fabs (__real__ retval) < DBL_MIN)
+           {
+             volatile double force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabs (__imag__ retval) < DBL_MIN)
+           {
+             volatile double force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
index de7e7d302a49578d8a20fb0b47a391dc49534a0e..62bf83c05bfaec594bc9361925cd84c9dea54444 100644 (file)
@@ -82,6 +82,19 @@ __ccoshf (__complex__ float x)
              __real__ retval = __ieee754_coshf (__real__ x) * cosix;
              __imag__ retval = __ieee754_sinhf (__real__ x) * sinix;
            }
+
+         if (fabsf (__real__ retval) < FLT_MIN)
+           {
+             volatile float force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabsf (__imag__ retval) < FLT_MIN)
+           {
+             volatile float force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
index 4bbd31148f805c0bf5ab890a2b733de4a783d489..18d3df04303cdda4ace73e250ac4ba9e95d28fcb 100644 (file)
@@ -82,6 +82,19 @@ __ccoshl (__complex__ long double x)
              __real__ retval = __ieee754_coshl (__real__ x) * cosix;
              __imag__ retval = __ieee754_sinhl (__real__ x) * sinix;
            }
+
+         if (fabsl (__real__ retval) < LDBL_MIN)
+           {
+             volatile long double force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabsl (__imag__ retval) < LDBL_MIN)
+           {
+             volatile long double force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
index cc1c9cd7ab5a5f6b07a646bad88b073dd6dbd916..6d28e4c1b94a002430aa6678181b765f541193d2 100644 (file)
@@ -88,6 +88,19 @@ __csin (__complex__ double x)
 
          if (negate)
            __real__ retval = -__real__ retval;
+
+         if (fabs (__real__ retval) < DBL_MIN)
+           {
+             volatile double force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabs (__imag__ retval) < DBL_MIN)
+           {
+             volatile double force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
index 92b858ae6a76c54b5211cd65d6fed51f96da04e8..a3dcf9d3aa3c4447d70e7fd230347147361450a9 100644 (file)
@@ -88,6 +88,19 @@ __csinf (__complex__ float x)
 
          if (negate)
            __real__ retval = -__real__ retval;
+
+         if (fabsf (__real__ retval) < FLT_MIN)
+           {
+             volatile float force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabsf (__imag__ retval) < FLT_MIN)
+           {
+             volatile float force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
index be3c6bbb87a8d09e72e26fd5cf9752cf229a4b4b..5a98f67851bfcde7b7d2d55fdd3108c02ee93536 100644 (file)
@@ -88,6 +88,19 @@ __csinh (__complex__ double x)
 
          if (negate)
            __real__ retval = -__real__ retval;
+
+         if (fabs (__real__ retval) < DBL_MIN)
+           {
+             volatile double force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabs (__imag__ retval) < DBL_MIN)
+           {
+             volatile double force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
index 6c58c1d0d2b81a42db2d254c6f11a30cf6a923d8..3658805fcbd33a51fa3189dac9061845fd70bfb9 100644 (file)
@@ -88,6 +88,19 @@ __csinhf (__complex__ float x)
 
          if (negate)
            __real__ retval = -__real__ retval;
+
+         if (fabsf (__real__ retval) < FLT_MIN)
+           {
+             volatile float force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabsf (__imag__ retval) < FLT_MIN)
+           {
+             volatile float force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
index 8acf6dec52e3a3f869ea9ee025fe8e383a3c0881..54a13fdda23721285cced950938824e73b744c11 100644 (file)
@@ -88,6 +88,19 @@ __csinhl (__complex__ long double x)
 
          if (negate)
            __real__ retval = -__real__ retval;
+
+         if (fabsl (__real__ retval) < LDBL_MIN)
+           {
+             volatile long double force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabsl (__imag__ retval) < LDBL_MIN)
+           {
+             volatile long double force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
index 6b3c1ea2f1231d1ee7c414b42dd7e53673986f4c..4d6ce3db356694ce5b7707604eaa3e95fecd5bb2 100644 (file)
@@ -88,6 +88,19 @@ __csinl (__complex__ long double x)
 
          if (negate)
            __real__ retval = -__real__ retval;
+
+         if (fabsl (__real__ retval) < LDBL_MIN)
+           {
+             volatile long double force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabsl (__imag__ retval) < LDBL_MIN)
+           {
+             volatile long double force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
This page took 0.153804 seconds and 5 git commands to generate.