bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mathl warnings


From: Paolo Bonzini
Subject: Re: mathl warnings
Date: Tue, 15 Apr 2008 15:29:44 +0200
User-agent: Thunderbird 2.0.0.12 (Macintosh/20080213)


The mathl module, compiled on Cygwin with -Wall, yields several warnings:

1)
acosl.c:186: warning: implicit declaration of function `asinl'
acosl.c:186: warning: implicit declaration of function `sqrtl'
asinl.c:186: warning: implicit declaration of function `sqrtl'

Calling functions with 'long double' results when they are not declared
most often yields wrong results, so this is probably not harmless.

This should be taken care of by the include of <math.h> at the top of the file. I'd rather leave it to the gnulib hackers to understand it, because I didn't write that part.

Regarding the rest, I committed the attached patch to fix the problems. Thanks.

2)
trigl.c:217: warning: suggest explicit braces to avoid ambiguous `else'

Look at trigl.c lines 215-216. The condition on x can never be true. What
is the purpose of this code?

The wrong range is checked, I reorganized it to also avoid the warning (which was a red herring).

3)
tanl.c:128: warning: 'flag' might be used uninitialized in this function

The 'flag' is indeed used uninitialized.

Looking at the original glibc code, it must be initialized to 0. I renamed it to invert.

Paolo
2008-04-15  Paolo Bonzini  <address@hidden>

        * lib/tanl.c (kernel_tanl): Rename flag to invert, initialize it
        to 0.
        * lib/trigl.c (ieee754_rem_pio2l): Fix range checks.

diff --git a/lib/tanl.c b/lib/tanl.c
index 64a84b8..11b63ad 100644
--- a/lib/tanl.c
+++ b/lib/tanl.c
@@ -125,7 +125,7 @@ long double
 kernel_tanl (long double x, long double y, int iy)
 {
   long double z, r, v, w, s, u, u1;
-  int flag, sign;
+  int invert = 0, sign;
 
   sign = 1;
   if (x < 0)
@@ -147,7 +147,7 @@ kernel_tanl (long double x, long double y, int iy)
     }
   if (x >= 0.6743316650390625) /* |x| >= 0.6743316650390625 */
     {
-      flag = 1;
+      invert = 1;
 
       z = pio4hi - x;
       w = pio4lo - y;
@@ -163,7 +163,7 @@ kernel_tanl (long double x, long double y, int iy)
   r = y + z * (s * r + y);
   r += TH * s;
   w = x + r;
-  if (flag)
+  if (invert)
     {
       v = (long double) iy;
       w = (v - 2.0 * (x - (w * w / (w + v) - r)));
diff --git a/lib/trigl.c b/lib/trigl.c
index ecdce32..6f9dcf5 100644
--- a/lib/trigl.c
+++ b/lib/trigl.c
@@ -205,7 +205,7 @@ ieee754_rem_pio2l (long double x, long double *y)
   int exp, n;
 
   if (x >= -0.78539816339744830961566084581987572104929234984377
-      && x < 0.78539816339744830961566084581987572104929234984377)
+      && x <= 0.78539816339744830961566084581987572104929234984377)
     /* x in <-pi/4, pi/4> */
     {
       y[0] = x;
@@ -213,9 +213,7 @@ ieee754_rem_pio2l (long double x, long double *y)
       return 0;
     }
 
-  if (x >= 2.35619449019234492884698253745962716314787704953131
-      && x < 2.35619449019234492884698253745962716314787704953131)
-    if (x > 0)
+  if (x > 0 && x < 2.35619449019234492884698253745962716314787704953131)
       {
        /* 113 + 93 bit PI is ok */
        z = x - PI_2_1;
@@ -223,7 +221,8 @@ ieee754_rem_pio2l (long double x, long double *y)
        y[1] = (z - y[0]) - PI_2_1t;
        return 1;
       }
-    else
+
+  if (x < 0 && x > -2.35619449019234492884698253745962716314787704953131)
       {
        /* 113 + 93 bit PI is ok */
        z = x + PI_2_1;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]