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
       {
