[PATCHv6] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
Commit Message
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(+)
Comments
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]).
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
@@ -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.
@@ -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);
}
@@ -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);
}
@@ -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);
}
@@ -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);
}