This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix ynl return value with LDBL_MIN
On Mon, May 28, 2012 at 10:00:04AM -0400, Carlos O'Donell wrote:
> Please prepare a testcase for this. We need to be serious about
> preventing regressions with these kinds of fixes.
Ok, now with testcase. Whether the actual fix is correct is
a different thing. Tested x86_64.
2012-05-28 Marek Polacek <polacek@redhat.com>
[BZ #14173]
* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_ynl): Correct
loop condition.
* math/Makefile (tests): Add tst-yn-retval.
* math/tst-yn-retval.c: New file.
--- libc/math/Makefile.mp 2012-05-28 15:58:25.252319135 +0200
+++ libc/math/Makefile 2012-05-28 16:29:05.881293430 +0200
@@ -88,7 +88,7 @@ long-c-yes = $(calls:=l)
tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret \
bug-nextafter bug-nexttoward bug-tgmath1 test-tgmath-int \
- test-tgmath2 test-powl tst-CMPLX tst-CMPLX2
+ test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 tst-yn-retval
# We do the `long double' tests only if this data type is available and
# distinct from `double'.
test-longdouble-yes = test-ldouble test-ildoubl
--- libc/math/tst-yn-retval.c.mp 2012-05-28 16:30:46.925541445 +0200
+++ libc/math/tst-yn-retval.c 2012-05-28 17:51:00.752067800 +0200
@@ -0,0 +1,45 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <float.h>
+#include <math.h>
+#include <stdio.h>
+
+static int
+do_test (void)
+{
+ int result = 0;
+
+ float f = ynf (10, FLT_MIN);
+ result |= ! isinf (f);
+ printf ("%f\n", f);
+
+ double d = yn (10, DBL_MIN);
+ result |= ! isinf (d);
+ printf ("%f\n", d);
+
+#ifndef NO_LONG_DOUBLE
+ long double ld = ynl (10, LDBL_MIN);
+ result |= ! isinf (ld);
+ printf ("%Lf\n", ld);
+#endif
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
--- libc/sysdeps/ieee754/ldbl-96/e_jnl.c.mp 2012-05-28 15:22:41.840423694 +0200
+++ libc/sysdeps/ieee754/ldbl-96/e_jnl.c 2012-05-28 18:19:59.792893995 +0200
@@ -360,7 +360,8 @@ __ieee754_ynl (int n, long double x)
b = __ieee754_y1l (x);
/* quit if b is -inf */
GET_LDOUBLE_WORDS (se, i0, i1, b);
- for (i = 1; i < n && se != 0xffff; i++)
+ /* Use 0xffffffff since GET_LDOUBLE_WORDS sign-extends SE. */
+ for (i = 1; i < n && se != 0xffffffff; i++)
{
temp = b;
b = ((long double) (i + i) / x) * b - a;
Marek