public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCHv3] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
       [not found] <20180930135031.GE1449@jam>
@ 2018-09-30 15:51 ` Martin Jansa
  2018-09-30 16:53   ` Joseph Myers
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Jansa @ 2018-09-30 15:51 UTC (permalink / raw)
  To: libc-alpha; +Cc: Martin Jansa

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);
      ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_jn':
../sysdeps/ieee754/dbl-64/e_jn.c:113:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      b = invsqrtpi * temp / sqrt (x);
          ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_yn':
../sysdeps/ieee754/dbl-64/e_jn.c:320:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  b = invsqrtpi * temp / sqrt (x);
      ~~~~~~~~~~^~~~~~

Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
with -O, -O1, -Os.
For soft-fp ARM it needs one more fix for -O1:
https://sourceware.org/ml/libc-alpha/2018-09/msg00300.html
For AARCH64 it needs one more fix in locale for -Os.

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

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 ChangeLog                           |  7 +++++++
 sysdeps/ieee754/dbl-64/e_jn.c       | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-128/e_jnl.c    | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-128ibm/e_jnl.c | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-96/e_jnl.c     | 21 +++++++++++++++++++++
 5 files changed, 91 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 07760299e6..4bafeefda5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-29  Martin Jansa  <Martin.Jansa@gmail.com>
+	Partial fix for [BZ #23716]
+	* sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O
+	* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.
+
 2018-09-28  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/fromfp.h: Do not include <math_private.h>.
diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
index aff06ead16..2d8bafbcce 100644
--- a/sysdeps/ieee754/dbl-64/e_jn.c
+++ b/sysdeps/ieee754/dbl-64/e_jn.c
@@ -43,6 +43,7 @@
 #include <math_private.h>
 #include <fenv_private.h>
 #include <math-underflow.h>
+#include <libc-diag.h>
 
 static const double
   invsqrtpi = 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
@@ -110,7 +111,17 @@ __ieee754_jn (int n, double x)
 	      case 2: temp = -c - s; break;
 	      case 3: temp = c - s; break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false possitive with -O1 and lower. */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrt (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -317,7 +328,17 @@ __ieee754_yn (int n, double x)
 	  case 2: temp = -s + c; break;
 	  case 3: temp = s + c; break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false possitive with -O1 and lower. */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrt (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index 7610d18c67..776da664dd 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/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 _Float128
   invsqrtpi = L(5.6418958354775628694807945156077258584405E-1),
@@ -151,7 +152,17 @@ __ieee754_jnl (int n, _Float128 x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false possitive with -O1 and lower. */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -387,7 +398,17 @@ __ieee754_ynl (int n, _Float128 x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false possitive with -O1 and lower. */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
index 50b4558e74..fcc2e2fae6 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/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.6418958354775628694807945156077258584405E-1L,
@@ -151,7 +152,17 @@ __ieee754_jnl (int n, long double x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false possitive with -O1 and lower. */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -387,7 +398,17 @@ __ieee754_ynl (int n, long double x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false possitive with -O1 and lower. */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 855190841b..650ff19539 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,17 @@ __ieee754_jnl (int n, long double x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false possitive with -O1 and lower. */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -373,7 +384,17 @@ __ieee754_ynl (int n, long double x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false possitive with -O1 and lower. */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv3] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-09-30 15:51 ` [PATCHv3] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444] Martin Jansa
@ 2018-09-30 16:53   ` Joseph Myers
  2018-09-30 17:57     ` Martin Jansa
  0 siblings, 1 reply; 16+ messages in thread
From: Joseph Myers @ 2018-09-30 16:53 UTC (permalink / raw)
  To: Martin Jansa; +Cc: libc-alpha

On Sun, 30 Sep 2018, Martin Jansa wrote:

> +	    /* With GCC 8 (and older) when compiling with -O the compiler
> +	       warns that the variable 'temp', may be used uninitialized.
> +	       The switch above covers all possible values of n & 3
> +	       but GCC without VRP enabled isn't able to figure out the
> +	       range of possible values is [0,3] as explained in:
> +	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
> +	       so it's false possitive with -O1 and lower. */

"positive" (for all such comments).  Also note there should be two spaces 
at the end of a comment between "." and the trailing "*/".

Are you sure about the "and lower", or is this warning disabled for -O0?  
(glibc disallows building with -O0 at present, but I think we *should* fix 
things to be able to build with -O0, because being able to build with -O0 
would be helpful for debugging - any particular pieces needing 
optimization should then just have it force-enabled, or functions declared 
as always_inline, or whatever is needed, locally.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv3] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-09-30 16:53   ` Joseph Myers
@ 2018-09-30 17:57     ` Martin Jansa
  2018-09-30 22:01       ` Martin Jansa
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Jansa @ 2018-09-30 17:57 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1991 bytes --]

On Sun, Sep 30, 2018 at 04:52:56PM +0000, Joseph Myers wrote:
> On Sun, 30 Sep 2018, Martin Jansa wrote:
> 
> > +	    /* With GCC 8 (and older) when compiling with -O the compiler
> > +	       warns that the variable 'temp', may be used uninitialized.
> > +	       The switch above covers all possible values of n & 3
> > +	       but GCC without VRP enabled isn't able to figure out the
> > +	       range of possible values is [0,3] as explained in:
> > +	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
> > +	       so it's false possitive with -O1 and lower. */
> 
> "positive" (for all such comments).  Also note there should be two spaces 
> at the end of a comment between "." and the trailing "*/".

OK, will update.

> Are you sure about the "and lower", or is this warning disabled for -O0?

I'm pretty sure that -ftree-vrp isn't enabled with -O0, but will retry
if it also shows this warning with -O0.

> (glibc disallows building with -O0 at present, but I think we *should* fix 
> things to be able to build with -O0, because being able to build with -O0 
> would be helpful for debugging - any particular pieces needing 
> optimization should then just have it force-enabled, or functions declared 
> as always_inline, or whatever is needed, locally.)

I agree, but I'm not volunteering to fix all of -O0 issues reported in
[BZ #19444], my motivation was just to fix debug builds in Yocto which
is by default using -O (and issues with -Os which I'm using for some of
my builds):
http://lists.openembedded.org/pipermail/openembedded-core/2018-September/155693.html

Fixing:
https://sourceware.org/glibc/wiki/FAQ#Why_do_I_get:.60.23error_.22glibc_cannot_be_compiled_without_optimization.22.27.2C_when_trying_to_compile_GNU_libc_with_GNU_CC.3F
is out of my league and time I'm willing to spend, I'll leave it to
someone more knowledgable about glibc internals.

Cheers,
-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv3] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-09-30 17:57     ` Martin Jansa
@ 2018-09-30 22:01       ` Martin Jansa
  2018-09-30 22:01         ` [PATCHv4] " Martin Jansa
  2018-09-30 22:16         ` [PATCHv5] " Martin Jansa
  0 siblings, 2 replies; 16+ messages in thread
From: Martin Jansa @ 2018-09-30 22:01 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 9252 bytes --]

On Sun, Sep 30, 2018 at 07:57:11PM +0200, Martin Jansa wrote:
> On Sun, Sep 30, 2018 at 04:52:56PM +0000, Joseph Myers wrote:
> > On Sun, 30 Sep 2018, Martin Jansa wrote:
> > 
> > > +	    /* With GCC 8 (and older) when compiling with -O the compiler
> > > +	       warns that the variable 'temp', may be used uninitialized.
> > > +	       The switch above covers all possible values of n & 3
> > > +	       but GCC without VRP enabled isn't able to figure out the
> > > +	       range of possible values is [0,3] as explained in:
> > > +	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
> > > +	       so it's false possitive with -O1 and lower. */
> > 
> > "positive" (for all such comments).  Also note there should be two spaces 
> > at the end of a comment between "." and the trailing "*/".
> 
> OK, will update.
> 
> > Are you sure about the "and lower", or is this warning disabled for -O0?
> 
> I'm pretty sure that -ftree-vrp isn't enabled with -O0, but will retry
> if it also shows this warning with -O0.

You were right, it warning isn't triggered with -O0, I'll drop the " and
lower" part in v4.

docker-shr @ ~/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/git/math $ x86_64-oe-linux-gcc  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse  --sysroot=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot ../sysdeps/ieee754/ldbl-96/e_jnl.c -c -std=gnu11 -fgnu89-inline  -O1 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0=/usr/src/debug/glibc/2.28-r0 -fdebug-prefix-map=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot= -fdebug-prefix-map=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot-native= -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fno-math-errno           -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES -I../include -I/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/math  -I/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux.gcc-cross-initial-x86_64/../../lib/x86_64-oe-linux.gcc-cross-initial-x86_64/gcc/x86_64-oe-linux/8.2.0/include -isystem /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux.gcc-cross-initial-x86_64/../../lib/x86_64-oe-linux.gcc-cross-initial-x86_64/gcc/x86_64-oe-linux/8.2.0/include-fixed -isystem /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot/usr/include  -D_LIBC_REENTRANT -include /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/libc-modules.h -DMODULE_NAME=libm -include ../include/libc-symbols.h       -DTOP_NAMESPACE=glibc -I../soft-fp -o /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/math/e_jnl.o -MD -MP -MF /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/math/e_jnl.o.dt -MT /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/math/e_jnl.o
../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_jnl':
../sysdeps/ieee754/ldbl-96/e_jnl.c:147: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:376:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  b = invsqrtpi * temp / sqrtl (x);
      ~~~~~~~~~~^~~~~~
cc1: all warnings being treated as errors
docker-shr @ ~/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/git/math $ x86_64-oe-linux-gcc  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse  --sysroot=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot ../sysdeps/ieee754/ldbl-96/e_jnl.c -c -std=gnu11 -fgnu89-inline  -O0 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0=/usr/src/debug/glibc/2.28-r0 -fdebug-prefix-map=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot= -fdebug-prefix-map=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot-native= -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fno-math-errno           -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES -I../include -I/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/math  -I/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux.gcc-cross-initial-x86_64/../../lib/x86_64-oe-linux.gcc-cross-initial-x86_64/gcc/x86_64-oe-linux/8.2.0/include -isystem /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux.gcc-cross-initial-x86_64/../../lib/x86_64-oe-linux.gcc-cross-initial-x86_64/gcc/x86_64-oe-linux/8.2.0/include-fixed -isystem /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/recipe-sysroot/usr/include  -D_LIBC_REENTRANT -include /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/libc-modules.h -DMODULE_NAME=libm -include ../include/libc-symbols.h       -DTOP_NAMESPACE=glibc -I../soft-fp -o /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/math/e_jnl.o -MD -MP -MF /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/math/e_jnl.o.dt -MT /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/glibc/2.28-r0/build-x86_64-oe-linux/math/e_jnl.o

> > (glibc disallows building with -O0 at present, but I think we *should* fix 
> > things to be able to build with -O0, because being able to build with -O0 
> > would be helpful for debugging - any particular pieces needing 
> > optimization should then just have it force-enabled, or functions declared 
> > as always_inline, or whatever is needed, locally.)
> 
> I agree, but I'm not volunteering to fix all of -O0 issues reported in
> [BZ #19444], my motivation was just to fix debug builds in Yocto which
> is by default using -O (and issues with -Os which I'm using for some of
> my builds):
> http://lists.openembedded.org/pipermail/openembedded-core/2018-September/155693.html
> 
> Fixing:
> https://sourceware.org/glibc/wiki/FAQ#Why_do_I_get:.60.23error_.22glibc_cannot_be_compiled_without_optimization.22.27.2C_when_trying_to_compile_GNU_libc_with_GNU_CC.3F
> is out of my league and time I'm willing to spend, I'll leave it to
> someone more knowledgable about glibc internals.
> 
> Cheers,
> -- 
> Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com



-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCHv4] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-09-30 22:01       ` Martin Jansa
@ 2018-09-30 22:01         ` Martin Jansa
  2018-10-01  7:28           ` Andreas Schwab
  2018-09-30 22:16         ` [PATCHv5] " Martin Jansa
  1 sibling, 1 reply; 16+ messages in thread
From: Martin Jansa @ 2018-09-30 22:01 UTC (permalink / raw)
  To: libc-alpha; +Cc: Martin Jansa

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);
      ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_jn':
../sysdeps/ieee754/dbl-64/e_jn.c:113:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      b = invsqrtpi * temp / sqrt (x);
          ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_yn':
../sysdeps/ieee754/dbl-64/e_jn.c:320:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  b = invsqrtpi * temp / sqrt (x);
      ~~~~~~~~~~^~~~~~

Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
with -O, -O1, -Os.
For soft-fp ARM it needs one more fix for -O1:
https://sourceware.org/ml/libc-alpha/2018-09/msg00300.html
For AARCH64 it needs one more fix in locale for -Os.

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

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 ChangeLog                           |  7 +++++++
 sysdeps/ieee754/dbl-64/e_jn.c       | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-128/e_jnl.c    | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-128ibm/e_jnl.c | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-96/e_jnl.c     | 21 +++++++++++++++++++++
 5 files changed, 91 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 07760299e6..4bafeefda5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-29  Martin Jansa  <Martin.Jansa@gmail.com>
+	Partial fix for [BZ #23716]
+	* sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O
+	* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.
+
 2018-09-28  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/fromfp.h: Do not include <math_private.h>.
diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
index aff06ead16..9ecc1da138 100644
--- a/sysdeps/ieee754/dbl-64/e_jn.c
+++ b/sysdeps/ieee754/dbl-64/e_jn.c
@@ -43,6 +43,7 @@
 #include <math_private.h>
 #include <fenv_private.h>
 #include <math-underflow.h>
+#include <libc-diag.h>
 
 static const double
   invsqrtpi = 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
@@ -110,7 +111,17 @@ __ieee754_jn (int n, double x)
 	      case 2: temp = -c - s; break;
 	      case 3: temp = c - s; break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false ositive with -O1.  */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrt (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -317,7 +328,17 @@ __ieee754_yn (int n, double x)
 	  case 2: temp = -s + c; break;
 	  case 3: temp = s + c; break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false ositive with -O1.  */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrt (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index 7610d18c67..ff14e19273 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/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 _Float128
   invsqrtpi = L(5.6418958354775628694807945156077258584405E-1),
@@ -151,7 +152,17 @@ __ieee754_jnl (int n, _Float128 x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false ositive with -O1.  */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -387,7 +398,17 @@ __ieee754_ynl (int n, _Float128 x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false ositive with -O1.  */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
index 50b4558e74..096da7106f 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/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.6418958354775628694807945156077258584405E-1L,
@@ -151,7 +152,17 @@ __ieee754_jnl (int n, long double x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false ositive with -O1.  */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -387,7 +398,17 @@ __ieee754_ynl (int n, long double x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false ositive with -O1.  */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 855190841b..8dc5b8f045 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,17 @@ __ieee754_jnl (int n, long double x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false ositive with -O1.  */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -373,7 +384,17 @@ __ieee754_ynl (int n, long double x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false ositive with -O1.  */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCHv5] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-09-30 22:01       ` Martin Jansa
  2018-09-30 22:01         ` [PATCHv4] " Martin Jansa
@ 2018-09-30 22:16         ` Martin Jansa
  2018-12-17 18:19           ` [PATCHv6] " Martin Jansa
  1 sibling, 1 reply; 16+ messages in thread
From: Martin Jansa @ 2018-09-30 22:16 UTC (permalink / raw)
  To: libc-alpha; +Cc: Martin Jansa

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);
      ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_jn':
../sysdeps/ieee754/dbl-64/e_jn.c:113:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      b = invsqrtpi * temp / sqrt (x);
          ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_yn':
../sysdeps/ieee754/dbl-64/e_jn.c:320:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  b = invsqrtpi * temp / sqrt (x);
      ~~~~~~~~~~^~~~~~

Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
with -O, -O1, -Os.
For soft-fp ARM it needs one more fix for -O1:
https://sourceware.org/ml/libc-alpha/2018-09/msg00300.html
For AARCH64 it needs one more fix in locale for -Os.

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

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 ChangeLog                           |  7 +++++++
 sysdeps/ieee754/dbl-64/e_jn.c       | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-128/e_jnl.c    | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-128ibm/e_jnl.c | 21 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-96/e_jnl.c     | 21 +++++++++++++++++++++
 5 files changed, 91 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 07760299e6..4bafeefda5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-29  Martin Jansa  <Martin.Jansa@gmail.com>
+	Partial fix for [BZ #23716]
+	* sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O
+	* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.
+
 2018-09-28  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/fromfp.h: Do not include <math_private.h>.
diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
index aff06ead16..e5546ff303 100644
--- a/sysdeps/ieee754/dbl-64/e_jn.c
+++ b/sysdeps/ieee754/dbl-64/e_jn.c
@@ -43,6 +43,7 @@
 #include <math_private.h>
 #include <fenv_private.h>
 #include <math-underflow.h>
+#include <libc-diag.h>
 
 static const double
   invsqrtpi = 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
@@ -110,7 +111,17 @@ __ieee754_jn (int n, double x)
 	      case 2: temp = -c - s; break;
 	      case 3: temp = c - s; break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false positive with -O1.  */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrt (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -317,7 +328,17 @@ __ieee754_yn (int n, double x)
 	  case 2: temp = -s + c; break;
 	  case 3: temp = s + c; break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false positive with -O1.  */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrt (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index 7610d18c67..def41a8215 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/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 _Float128
   invsqrtpi = L(5.6418958354775628694807945156077258584405E-1),
@@ -151,7 +152,17 @@ __ieee754_jnl (int n, _Float128 x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false positive with -O1.  */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -387,7 +398,17 @@ __ieee754_ynl (int n, _Float128 x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false positive with -O1.  */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
index 50b4558e74..52a58dc6aa 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/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.6418958354775628694807945156077258584405E-1L,
@@ -151,7 +152,17 @@ __ieee754_jnl (int n, long double x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false positive with -O1.  */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -387,7 +398,17 @@ __ieee754_ynl (int n, long double x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false positive with -O1.  */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 855190841b..2c13c8ec16 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,17 @@ __ieee754_jnl (int n, long double x)
 		temp = c - s;
 		break;
 	      }
+	    /* With GCC 8 (and older) when compiling with -O the compiler
+	       warns that the variable 'temp', may be used uninitialized.
+	       The switch above covers all possible values of n & 3
+	       but GCC without VRP enabled isn't able to figure out the
+	       range of possible values is [0,3] as explained in:
+	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	       so it's false positive with -O1.  */
+	    DIAG_PUSH_NEEDS_COMMENT;
+	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	    b = invsqrtpi * temp / sqrtl (x);
+	    DIAG_POP_NEEDS_COMMENT;
 	  }
 	else
 	  {
@@ -373,7 +384,17 @@ __ieee754_ynl (int n, long double x)
 	    temp = s + c;
 	    break;
 	  }
+	/* With GCC 8 (and older) when compiling with -O the compiler
+	   warns that the variable 'temp', may be used uninitialized.
+	   The switch above covers all possible values of n & 3
+	   but GCC without VRP enabled isn't able to figure out the
+	   range of possible values is [0,3] as explained in:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
+	   so it's false positive with -O1.  */
+	DIAG_PUSH_NEEDS_COMMENT;
+	DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
 	b = invsqrtpi * temp / sqrtl (x);
+	DIAG_POP_NEEDS_COMMENT;
       }
     else
       {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv4] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-09-30 22:01         ` [PATCHv4] " Martin Jansa
@ 2018-10-01  7:28           ` Andreas Schwab
  2018-10-02 16:57             ` Joseph Myers
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Schwab @ 2018-10-01  7:28 UTC (permalink / raw)
  To: Martin Jansa; +Cc: libc-alpha

On Sep 30 2018, Martin Jansa <martin.jansa@gmail.com> wrote:

> @@ -110,7 +111,17 @@ __ieee754_jn (int n, double x)
>  	      case 2: temp = -c - s; break;
>  	      case 3: temp = c - s; break;
>  	      }
> +	    /* With GCC 8 (and older) when compiling with -O the compiler
> +	       warns that the variable 'temp', may be used uninitialized.
> +	       The switch above covers all possible values of n & 3
> +	       but GCC without VRP enabled isn't able to figure out the
> +	       range of possible values is [0,3] as explained in:
> +	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
> +	       so it's false ositive with -O1.  */
> +	    DIAG_PUSH_NEEDS_COMMENT;
> +	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
>  	    b = invsqrtpi * temp / sqrt (x);
> +	    DIAG_POP_NEEDS_COMMENT;

How about adding __builtin_unreachable instead?  That doesn't add any
code, but helps the compiler seeing the whole picture.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv4] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-10-01  7:28           ` Andreas Schwab
@ 2018-10-02 16:57             ` Joseph Myers
  0 siblings, 0 replies; 16+ messages in thread
From: Joseph Myers @ 2018-10-02 16:57 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Martin Jansa, libc-alpha

On Mon, 1 Oct 2018, Andreas Schwab wrote:

> How about adding __builtin_unreachable instead?  That doesn't add any
> code, but helps the compiler seeing the whole picture.

Yes, adding default: __builtin_unreachable (); to the switch statements in 
question seems reasonable as an approach for these particular 
uninitialized warnings (it only works for cases like this where there's a 
suitable place to add such a call, of course).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCHv6] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-09-30 22:16         ` [PATCHv5] " Martin Jansa
@ 2018-12-17 18:19           ` Martin Jansa
  2018-12-17 21:31             ` Joseph Myers
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Jansa @ 2018-12-17 18:19 UTC (permalink / raw)
  To: libc-alpha; +Cc: schwab, joseph, Martin Jansa

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);
      ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_jn':
../sysdeps/ieee754/dbl-64/e_jn.c:113:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      b = invsqrtpi * temp / sqrt (x);
          ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_yn':
../sysdeps/ieee754/dbl-64/e_jn.c:320:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  b = invsqrtpi * temp / sqrt (x);
      ~~~~~~~~~~^~~~~~

Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
with -O, -O1, -Os.
For soft-fp ARM it needs one more fix for -O1:
https://sourceware.org/ml/libc-alpha/2018-09/msg00300.html
For AARCH64 it needs one more fix in locale for -Os.

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

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 ChangeLog                           | 7 +++++++
 sysdeps/ieee754/dbl-64/e_jn.c       | 2 ++
 sysdeps/ieee754/ldbl-128/e_jnl.c    | 4 ++++
 sysdeps/ieee754/ldbl-128ibm/e_jnl.c | 4 ++++
 sysdeps/ieee754/ldbl-96/e_jnl.c     | 4 ++++
 5 files changed, 21 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 99339f4605..b0a4515bf4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-12-17  Martin Jansa  <Martin.Jansa@gmail.com>
+	Partial fix for [BZ #19444]
+	* sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O
+	* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.
+
 2018-12-17  Mao Han  <han_mao@c-sky.com>
 
 	* sysdeps/unix/sysv/linux/Makefile: Add statx_cp.c.
diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
index aff06ead16..90a7e77270 100644
--- a/sysdeps/ieee754/dbl-64/e_jn.c
+++ b/sysdeps/ieee754/dbl-64/e_jn.c
@@ -109,6 +109,7 @@ __ieee754_jn (int n, double x)
 	      case 1: temp = -c + s; break;
 	      case 2: temp = -c - s; break;
 	      case 3: temp = c - s; break;
+	      default: __builtin_unreachable ();
 	      }
 	    b = invsqrtpi * temp / sqrt (x);
 	  }
@@ -316,6 +317,7 @@ __ieee754_yn (int n, double x)
 	  case 1: temp = -s - c; break;
 	  case 2: temp = -s + c; break;
 	  case 3: temp = s + c; break;
+	  default: __builtin_unreachable ();
 	  }
 	b = invsqrtpi * temp / sqrt (x);
       }
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index 7610d18c67..3c90072a22 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/e_jnl.c
@@ -150,6 +150,8 @@ __ieee754_jnl (int n, _Float128 x)
 	      case 3:
 		temp = c - s;
 		break;
+	      default:
+		__builtin_unreachable ();
 	      }
 	    b = invsqrtpi * temp / sqrtl (x);
 	  }
@@ -386,6 +388,8 @@ __ieee754_ynl (int n, _Float128 x)
 	  case 3:
 	    temp = s + c;
 	    break;
+	  default:
+	    __builtin_unreachable ();
 	  }
 	b = invsqrtpi * temp / sqrtl (x);
       }
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
index 50b4558e74..478824c8fa 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
@@ -150,6 +150,8 @@ __ieee754_jnl (int n, long double x)
 	      case 3:
 		temp = c - s;
 		break;
+	      default:
+		__builtin_unreachable ();
 	      }
 	    b = invsqrtpi * temp / sqrtl (x);
 	  }
@@ -386,6 +388,8 @@ __ieee754_ynl (int n, long double x)
 	  case 3:
 	    temp = s + c;
 	    break;
+	  default:
+	    __builtin_unreachable ();
 	  }
 	b = invsqrtpi * temp / sqrtl (x);
       }
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 855190841b..6c1c4b4653 100644
--- a/sysdeps/ieee754/ldbl-96/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-96/e_jnl.c
@@ -143,6 +143,8 @@ __ieee754_jnl (int n, long double x)
 	      case 3:
 		temp = c - s;
 		break;
+	      default:
+		__builtin_unreachable ();
 	      }
 	    b = invsqrtpi * temp / sqrtl (x);
 	  }
@@ -372,6 +374,8 @@ __ieee754_ynl (int n, long double x)
 	  case 3:
 	    temp = s + c;
 	    break;
+	  default:
+	    __builtin_unreachable ();
 	  }
 	b = invsqrtpi * temp / sqrtl (x);
       }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv6] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-12-17 18:19           ` [PATCHv6] " Martin Jansa
@ 2018-12-17 21:31             ` Joseph Myers
  2018-12-17 21:32               ` Martin Jansa
  2018-12-17 21:36               ` [PATCHv7] " Martin Jansa
  0 siblings, 2 replies; 16+ messages in thread
From: Joseph Myers @ 2018-12-17 21:31 UTC (permalink / raw)
  To: Martin Jansa; +Cc: libc-alpha, schwab

On Mon, 17 Dec 2018, Martin Jansa wrote:

>         [BZ #23716]

This is the wrong bug number.

The patch is OK (with a blank line added in ChangeLog after the date line, 
before the line with [BZ #19444]).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv6] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-12-17 21:31             ` Joseph Myers
@ 2018-12-17 21:32               ` Martin Jansa
  2018-12-17 21:36               ` [PATCHv7] " Martin Jansa
  1 sibling, 0 replies; 16+ messages in thread
From: Martin Jansa @ 2018-12-17 21:32 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, schwab

[-- Attachment #1: Type: text/plain, Size: 573 bytes --]

On Mon, Dec 17, 2018 at 08:55:22PM +0000, Joseph Myers wrote:
> On Mon, 17 Dec 2018, Martin Jansa wrote:
> 
> >         [BZ #23716]
> 
> This is the wrong bug number.

You're right, I've fixed it in ChangeLog, but forgot to fix it in commit
message. I've also added ML reference to the last patch from the series
to the commit message while fixing this.

> The patch is OK (with a blank line added in ChangeLog after the date line, 
> before the line with [BZ #19444]).

Sending v7 now.

Thanks
-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCHv7] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-12-17 21:31             ` Joseph Myers
  2018-12-17 21:32               ` Martin Jansa
@ 2018-12-17 21:36               ` Martin Jansa
  2018-12-17 22:04                 ` Joseph Myers
  1 sibling, 1 reply; 16+ messages in thread
From: Martin Jansa @ 2018-12-17 21:36 UTC (permalink / raw)
  To: libc-alpha; +Cc: schwab, joseph, Martin Jansa

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);
      ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_jn':
../sysdeps/ieee754/dbl-64/e_jn.c:113:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      b = invsqrtpi * temp / sqrt (x);
          ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_yn':
../sysdeps/ieee754/dbl-64/e_jn.c:320:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  b = invsqrtpi * temp / sqrt (x);
      ~~~~~~~~~~^~~~~~

Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
with -O, -O1, -Os.
For soft-fp ARM it needs one more fix for -O1:
https://sourceware.org/ml/libc-alpha/2018-09/msg00300.html
For AARCH64 it needs one more fix in locale for -Os:
https://sourceware.org/ml/libc-alpha/2018-09/msg00539.html

        [BZ #19444]
        * sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O
        * sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
        * sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 ChangeLog                           | 8 ++++++++
 sysdeps/ieee754/dbl-64/e_jn.c       | 2 ++
 sysdeps/ieee754/ldbl-128/e_jnl.c    | 4 ++++
 sysdeps/ieee754/ldbl-128ibm/e_jnl.c | 4 ++++
 sysdeps/ieee754/ldbl-96/e_jnl.c     | 4 ++++
 5 files changed, 22 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 99339f4605..2e12129846 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-12-17  Martin Jansa  <Martin.Jansa@gmail.com>
+
+	Partial fix for [BZ #19444]
+	* sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O
+	* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.
+
 2018-12-17  Mao Han  <han_mao@c-sky.com>
 
 	* sysdeps/unix/sysv/linux/Makefile: Add statx_cp.c.
diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
index aff06ead16..90a7e77270 100644
--- a/sysdeps/ieee754/dbl-64/e_jn.c
+++ b/sysdeps/ieee754/dbl-64/e_jn.c
@@ -109,6 +109,7 @@ __ieee754_jn (int n, double x)
 	      case 1: temp = -c + s; break;
 	      case 2: temp = -c - s; break;
 	      case 3: temp = c - s; break;
+	      default: __builtin_unreachable ();
 	      }
 	    b = invsqrtpi * temp / sqrt (x);
 	  }
@@ -316,6 +317,7 @@ __ieee754_yn (int n, double x)
 	  case 1: temp = -s - c; break;
 	  case 2: temp = -s + c; break;
 	  case 3: temp = s + c; break;
+	  default: __builtin_unreachable ();
 	  }
 	b = invsqrtpi * temp / sqrt (x);
       }
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index 7610d18c67..3c90072a22 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/e_jnl.c
@@ -150,6 +150,8 @@ __ieee754_jnl (int n, _Float128 x)
 	      case 3:
 		temp = c - s;
 		break;
+	      default:
+		__builtin_unreachable ();
 	      }
 	    b = invsqrtpi * temp / sqrtl (x);
 	  }
@@ -386,6 +388,8 @@ __ieee754_ynl (int n, _Float128 x)
 	  case 3:
 	    temp = s + c;
 	    break;
+	  default:
+	    __builtin_unreachable ();
 	  }
 	b = invsqrtpi * temp / sqrtl (x);
       }
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
index 50b4558e74..478824c8fa 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
@@ -150,6 +150,8 @@ __ieee754_jnl (int n, long double x)
 	      case 3:
 		temp = c - s;
 		break;
+	      default:
+		__builtin_unreachable ();
 	      }
 	    b = invsqrtpi * temp / sqrtl (x);
 	  }
@@ -386,6 +388,8 @@ __ieee754_ynl (int n, long double x)
 	  case 3:
 	    temp = s + c;
 	    break;
+	  default:
+	    __builtin_unreachable ();
 	  }
 	b = invsqrtpi * temp / sqrtl (x);
       }
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 855190841b..6c1c4b4653 100644
--- a/sysdeps/ieee754/ldbl-96/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-96/e_jnl.c
@@ -143,6 +143,8 @@ __ieee754_jnl (int n, long double x)
 	      case 3:
 		temp = c - s;
 		break;
+	      default:
+		__builtin_unreachable ();
 	      }
 	    b = invsqrtpi * temp / sqrtl (x);
 	  }
@@ -372,6 +374,8 @@ __ieee754_ynl (int n, long double x)
 	  case 3:
 	    temp = s + c;
 	    break;
+	  default:
+	    __builtin_unreachable ();
 	  }
 	b = invsqrtpi * temp / sqrtl (x);
       }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv7] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-12-17 21:36               ` [PATCHv7] " Martin Jansa
@ 2018-12-17 22:04                 ` Joseph Myers
  2019-01-04  1:23                   ` Martin Jansa
  0 siblings, 1 reply; 16+ messages in thread
From: Joseph Myers @ 2018-12-17 22:04 UTC (permalink / raw)
  To: Martin Jansa; +Cc: libc-alpha, schwab

This patch is OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv7] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2018-12-17 22:04                 ` Joseph Myers
@ 2019-01-04  1:23                   ` Martin Jansa
  2019-01-04 16:19                     ` Joseph Myers
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Jansa @ 2019-01-04  1:23 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, schwab

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

On Mon, Dec 17, 2018 at 09:49:16PM +0000, Joseph Myers wrote:
> This patch is OK.

Hi,

if it's ok, can you please merge it?

I'm also still waiting for review (or merge) of the other one from this
thread:

"locale: prevent maybe-uninitialized errors with -Os [BZ #19444]"

Thanks,

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv7] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
  2019-01-04  1:23                   ` Martin Jansa
@ 2019-01-04 16:19                     ` Joseph Myers
  2019-01-04 23:37                       ` [PATCH COMMITTED] ChangeLog: Fix an obvious typo in the previous commit Rafal Luzynski
  0 siblings, 1 reply; 16+ messages in thread
From: Joseph Myers @ 2019-01-04 16:19 UTC (permalink / raw)
  To: Martin Jansa; +Cc: libc-alpha, schwab

On Fri, 4 Jan 2019, Martin Jansa wrote:

> On Mon, Dec 17, 2018 at 09:49:16PM +0000, Joseph Myers wrote:
> > This patch is OK.
> 
> Hi,
> 
> if it's ok, can you please merge it?

Done.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH COMMITTED] ChangeLog: Fix an obvious typo in the previous commit.
  2019-01-04 16:19                     ` Joseph Myers
@ 2019-01-04 23:37                       ` Rafal Luzynski
  0 siblings, 0 replies; 16+ messages in thread
From: Rafal Luzynski @ 2019-01-04 23:37 UTC (permalink / raw)
  To: libc-alpha


---
 ChangeLog | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index a71c88f..ca5d373 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-2019-10-04  Martin Jansa  <Martin.Jansa@gmail.com>
+2019-01-04  Martin Jansa  <Martin.Jansa@gmail.com>
 
 	[BZ #19444]
 	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Use
-- 
2.7.5

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-01-04 23:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20180930135031.GE1449@jam>
2018-09-30 15:51 ` [PATCHv3] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444] Martin Jansa
2018-09-30 16:53   ` Joseph Myers
2018-09-30 17:57     ` Martin Jansa
2018-09-30 22:01       ` Martin Jansa
2018-09-30 22:01         ` [PATCHv4] " Martin Jansa
2018-10-01  7:28           ` Andreas Schwab
2018-10-02 16:57             ` Joseph Myers
2018-09-30 22:16         ` [PATCHv5] " Martin Jansa
2018-12-17 18:19           ` [PATCHv6] " Martin Jansa
2018-12-17 21:31             ` Joseph Myers
2018-12-17 21:32               ` Martin Jansa
2018-12-17 21:36               ` [PATCHv7] " Martin Jansa
2018-12-17 22:04                 ` Joseph Myers
2019-01-04  1:23                   ` Martin Jansa
2019-01-04 16:19                     ` Joseph Myers
2019-01-04 23:37                       ` [PATCH COMMITTED] ChangeLog: Fix an obvious typo in the previous commit Rafal Luzynski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).