This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCHv2] sysdeps/ieee754: prevent maybe-uninitialized errors [BZ #19444]


With -O included in CFLAGS it fails to build with:

../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_jnl':
../sysdeps/ieee754/ldbl-96/e_jnl.c:146:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      b = invsqrtpi * temp / sqrtl (x);
          ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_ynl':
../sysdeps/ieee754/ldbl-96/e_jnl.c:375:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  b = invsqrtpi * temp / sqrtl (x);
      ~~~~~~~~~~^~~~~~

        [BZ #23716]
        * sysdeps/ieee754/ldbl-96/e_jnl.c: Fix build with -O

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 ChangeLog                       |  4 ++++
 sysdeps/ieee754/ldbl-96/e_jnl.c | 15 +++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 07760299e6..5066a4840d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-09-29  Martin Jansa  <Martin.Jansa@gmail.com>
+	Partial fix for [BZ #23716]
+	* sysdeps/ieee754/ldbl-96/e_jnl.c: Fix build with -O
+
 2018-09-28  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/fromfp.h: Do not include <math_private.h>.
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 855190841b..c5b27e7fcf 100644
--- a/sysdeps/ieee754/ldbl-96/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-96/e_jnl.c
@@ -62,6 +62,7 @@
 #include <math_private.h>
 #include <fenv_private.h>
 #include <math-underflow.h>
+#include <libc-diag.h>
 
 static const long double
   invsqrtpi = 5.64189583547756286948079e-1L, two = 2.0e0L, one = 1.0e0L;
@@ -144,7 +145,14 @@ __ieee754_jnl (int n, long double x)
 		temp = c - s;
 		break;
 	      }
+/* With GCC 8 when compiling with -O the compiler
+   warns that the variable 'temp',  may be used uninitialized.
+   The switch above should cover all possible values of n & 3
+   so I belive it's false possitive. */
+DIAG_PUSH_NEEDS_COMMENT;
+DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -373,7 +381,14 @@ __ieee754_ynl (int n, long double x)
 	    temp = s + c;
 	    break;
 	  }
+/* With GCC 8 when compiling with -O the compiler
+   warns that the variable 'temp',  may be used uninitialized.
+   The switch above should cover all possible values of n & 3
+   so I belive it's false possitive. */
+DIAG_PUSH_NEEDS_COMMENT;
+DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
-- 
2.17.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]