Patchwork [PATCHv3] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]

login
register
mail settings
Submitter Martin Jansa
Date Sept. 30, 2018, 3:51 p.m.
Message ID <20180930155134.32524-1-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/29586/
State New
Headers show

Comments

Martin Jansa - Sept. 30, 2018, 3:51 p.m.
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(+)
Joseph Myers - Sept. 30, 2018, 4:52 p.m.
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.)
Martin Jansa - Sept. 30, 2018, 5:57 p.m.
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 Jansa - Sept. 30, 2018, 10 p.m.
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

Patch

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
       {