From: Joseph Myers Date: Fri, 23 Aug 2013 19:45:38 +0000 (+0000) Subject: Fix cexp (NaN + i0) (bug 15532). X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85ce5db8d835281c8beff6e750c02c799dee3f6f;p=thirdparty%2Fglibc.git Fix cexp (NaN + i0) (bug 15532). --- diff --git a/ChangeLog b/ChangeLog index 7b4d6e9214a..1ffcad440b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2013-08-23 Joseph Myers + + [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-21 Joseph Myers [BZ #15797] diff --git a/NEWS b/NEWS index 0d0a315da51..c83a14e980d 100644 --- a/NEWS +++ b/NEWS @@ -20,9 +20,9 @@ Version 2.18 15335, 15336, 15337, 15339, 15342, 15346, 15359, 15361, 15366, 15380, 15381, 15394, 15395, 15405, 15406, 15409, 15416, 15418, 15419, 15423, 15424, 15426, 15429, 15431, 15432, 15441, 15442, 15448, 15465, 15480, - 15485, 15488, 15490, 15492, 15493, 15497, 15506, 15529, 15536, 15553, - 15577, 15583, 15618, 15627, 15631, 15654, 15655, 15666, 15667, 15674, - 15711, 15755, 15759, 15797. + 15485, 15488, 15490, 15492, 15493, 15497, 15506, 15529, 15532, 15536, + 15553, 15577, 15583, 15618, 15627, 15631, 15654, 15655, 15666, 15667, + 15674, 15711, 15755, 15759, 15797. * CVE-2013-2207 Incorrectly granting access to another user's pseudo-terminal has been fixed by disabling the use of pt_chown (Bugzilla #15755). diff --git a/math/libm-test.inc b/math/libm-test.inc index 8c1dcac8e8a..7408c6b312e 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -6193,7 +6193,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, 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, plus_infty, qnan_value, qnan_value, INVALID_EXCEPTION_OK), diff --git a/math/s_cexp.c b/math/s_cexp.c index 655e4e8deeb..40e0e518d2a 100644 --- a/math/s_cexp.c +++ b/math/s_cexp.c @@ -145,12 +145,18 @@ __cexp (__complex__ double x) } 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 (""); - __imag__ retval = __nan (""); + if (icls == FP_ZERO) + __imag__ retval = __imag__ x; + else + { + __imag__ retval = __nan (""); - if (rcls != FP_NAN || icls != FP_NAN) - feraiseexcept (FE_INVALID); + if (rcls != FP_NAN || icls != FP_NAN) + feraiseexcept (FE_INVALID); + } } return retval; diff --git a/math/s_cexpf.c b/math/s_cexpf.c index fa942d34f79..7c422051644 100644 --- a/math/s_cexpf.c +++ b/math/s_cexpf.c @@ -145,12 +145,18 @@ __cexpf (__complex__ float x) } 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 (""); - __imag__ retval = __nanf (""); + if (icls == FP_ZERO) + __imag__ retval = __imag__ x; + else + { + __imag__ retval = __nanf (""); - if (rcls != FP_NAN || icls != FP_NAN) - feraiseexcept (FE_INVALID); + if (rcls != FP_NAN || icls != FP_NAN) + feraiseexcept (FE_INVALID); + } } return retval; diff --git a/math/s_cexpl.c b/math/s_cexpl.c index d827bc3de41..0c356033666 100644 --- a/math/s_cexpl.c +++ b/math/s_cexpl.c @@ -145,12 +145,18 @@ __cexpl (__complex__ long double x) } 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 (""); - __imag__ retval = __nanl (""); + if (icls == FP_ZERO) + __imag__ retval = __imag__ x; + else + { + __imag__ retval = __nanl (""); - if (rcls != FP_NAN || icls != FP_NAN) - feraiseexcept (FE_INVALID); + if (rcls != FP_NAN || icls != FP_NAN) + feraiseexcept (FE_INVALID); + } } return retval;