1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00

Fix cexp (NaN + i0) (bug 15532).

This commit is contained in:
Joseph Myers
2013-08-23 19:45:38 +00:00
parent 936241e4b2
commit 8fe89494e6
6 changed files with 42 additions and 14 deletions

View File

@@ -1,3 +1,12 @@
2013-08-23 Joseph Myers <joseph@codesourcery.com>
[BZ #15532]
* math/s_cexp.c (__cexp): Return NaN + i0 for NaN + i0 argument.
* math/s_cexpf.c (__cexpf): Likewise.
* math/s_cexpl.c (__cexpl): Likewise.
* math/libm-test.inc (cexp_test_data): Correct expected return
value for NaN + i0. Add another test.
2013-08-22 David S. Miller <davem@davemloft.net> 2013-08-22 David S. Miller <davem@davemloft.net>
* po/ca.po: Update Catalan translation from translation project. * po/ca.po: Update Catalan translation from translation project.

2
NEWS
View File

@@ -9,7 +9,7 @@ Version 2.19
* The following bugs are resolved with this release: * The following bugs are resolved with this release:
14699, 15531, 15749, 15797, 15867 14699, 15531, 15532, 15749, 15797, 15867
* CVE-2013-4237 The readdir_r function could write more than NAME_MAX bytes * CVE-2013-4237 The readdir_r function could write more than NAME_MAX bytes
to the d_name member of struct dirent, or omit the terminating NUL to the d_name member of struct dirent, or omit the terminating NUL

View File

@@ -6198,7 +6198,8 @@ static const struct test_c_c_data cexp_test_data[] =
TEST_c_c (cexp, plus_infty, qnan_value, plus_infty, qnan_value), TEST_c_c (cexp, plus_infty, qnan_value, plus_infty, qnan_value),
TEST_c_c (cexp, qnan_value, 0.0, qnan_value, qnan_value, INVALID_EXCEPTION_OK), TEST_c_c (cexp, qnan_value, 0.0, qnan_value, 0.0),
TEST_c_c (cexp, qnan_value, minus_zero, qnan_value, minus_zero),
TEST_c_c (cexp, qnan_value, 1.0, qnan_value, qnan_value, INVALID_EXCEPTION_OK), TEST_c_c (cexp, qnan_value, 1.0, qnan_value, qnan_value, INVALID_EXCEPTION_OK),
TEST_c_c (cexp, qnan_value, plus_infty, qnan_value, qnan_value, INVALID_EXCEPTION_OK), TEST_c_c (cexp, qnan_value, plus_infty, qnan_value, qnan_value, INVALID_EXCEPTION_OK),

View File

@@ -145,12 +145,18 @@ __cexp (__complex__ double x)
} }
else else
{ {
/* If the real part is NaN the result is NaN + iNaN. */ /* If the real part is NaN the result is NaN + iNaN unless the
imaginary part is zero. */
__real__ retval = __nan (""); __real__ retval = __nan ("");
__imag__ retval = __nan (""); if (icls == FP_ZERO)
__imag__ retval = __imag__ x;
else
{
__imag__ retval = __nan ("");
if (rcls != FP_NAN || icls != FP_NAN) if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID); feraiseexcept (FE_INVALID);
}
} }
return retval; return retval;

View File

@@ -145,12 +145,18 @@ __cexpf (__complex__ float x)
} }
else else
{ {
/* If the real part is NaN the result is NaN + iNaN. */ /* If the real part is NaN the result is NaN + iNaN unless the
imaginary part is zero. */
__real__ retval = __nanf (""); __real__ retval = __nanf ("");
__imag__ retval = __nanf (""); if (icls == FP_ZERO)
__imag__ retval = __imag__ x;
else
{
__imag__ retval = __nanf ("");
if (rcls != FP_NAN || icls != FP_NAN) if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID); feraiseexcept (FE_INVALID);
}
} }
return retval; return retval;

View File

@@ -145,12 +145,18 @@ __cexpl (__complex__ long double x)
} }
else else
{ {
/* If the real part is NaN the result is NaN + iNaN. */ /* If the real part is NaN the result is NaN + iNaN unless the
imaginary part is zero. */
__real__ retval = __nanl (""); __real__ retval = __nanl ("");
__imag__ retval = __nanl (""); if (icls == FP_ZERO)
__imag__ retval = __imag__ x;
else
{
__imag__ retval = __nanl ("");
if (rcls != FP_NAN || icls != FP_NAN) if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID); feraiseexcept (FE_INVALID);
}
} }
return retval; return retval;