blob: 99cd2509ecf19d19c31e752a3d3ce0ee497d8361 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 618668540e263c09b0eb28131dde7b4500158fd4 Mon Sep 17 00:00:00 2001
2From: Martin Jansa <Martin.Jansa@gmail.com>
3Date: Sun, 16 Sep 2018 12:39:22 +0000
4Subject: [PATCH] sysdeps/ieee754/soft-fp: ignore maybe-uninitialized with -O
5 [BZ #19444]
6
7* with -O, -O1, -Os it fails with:
8
9In file included from ../soft-fp/soft-fp.h:318,
10 from ../sysdeps/ieee754/soft-fp/s_fdiv.c:28:
11../sysdeps/ieee754/soft-fp/s_fdiv.c: In function '__fdiv':
12../soft-fp/op-2.h:98:25: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized]
13 X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) \
14 ^~
15../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f1' was declared here
16 FP_DECL_D (R);
17 ^
18../soft-fp/op-2.h:37:36: note: in definition of macro '_FP_FRAC_DECL_2'
19 _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
20 ^
21../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
22 # define FP_DECL_D(X) _FP_DECL (2, X)
23 ^~~~~~~~
24../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
25 FP_DECL_D (R);
26 ^~~~~~~~~
27../soft-fp/op-2.h:101:17: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized]
28 : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \
29 ^~
30../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f0' was declared here
31 FP_DECL_D (R);
32 ^
33../soft-fp/op-2.h:37:14: note: in definition of macro '_FP_FRAC_DECL_2'
34 _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
35 ^
36../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
37 # define FP_DECL_D(X) _FP_DECL (2, X)
38 ^~~~~~~~
39../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
40 FP_DECL_D (R);
41 ^~~~~~~~~
42
43Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
44with -O, -O1, -Os.
45For AARCH64 it needs one more fix in locale for -Os.
46
47 Partial fix for [BZ #23716]
48 * sysdeps/ieee754/soft-fp/s_fdiv.c: Fix build with -O
49
50Work around the issue instead of removing -O like we do with
51SELECTED_OPTIMIZATION
52
53Upstream-Status: Submitted [https://www.sourceware.org/ml/libc-alpha/2018-09/msg00300.html]
54
55Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
56---
57 ChangeLog | 4 ++++
58 sysdeps/ieee754/soft-fp/s_fdiv.c | 12 ++++++++++++
59 2 files changed, 16 insertions(+)
60
61diff --git a/ChangeLog b/ChangeLog
62index 922e916f2c..216336edc9 100644
63--- a/ChangeLog
64+++ b/ChangeLog
65@@ -1,3 +1,7 @@
66+2018-09-30 Martin Jansa <Martin.Jansa@gmail.com>
67+ Partial fix for [BZ #23716]
68+ * sysdeps/ieee754/soft-fp/s_fdiv.c: Fix build with -O.
69+
70 2018-09-29 Martin Jansa <Martin.Jansa@gmail.com>
71 Partial fix for [BZ #23716]
72 * sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O
73diff --git a/sysdeps/ieee754/soft-fp/s_fdiv.c b/sysdeps/ieee754/soft-fp/s_fdiv.c
74index 341339f5ed..14655b77da 100644
75--- a/sysdeps/ieee754/soft-fp/s_fdiv.c
76+++ b/sysdeps/ieee754/soft-fp/s_fdiv.c
77@@ -25,6 +25,16 @@
78 #undef fdivl
79
80 #include <math-narrow.h>
81+
82+#include <libc-diag.h>
83+/* R_f[01] are not set in cases where it is not used in packing, but the
84+ compiler does not see that it is set in all cases where it is
85+ used, resulting in warnings that it may be used uninitialized.
86+ The location of the warning differs in different versions of GCC,
87+ it may be where R is defined using a macro or it may be where the
88+ macro is defined. */
89+DIAG_PUSH_NEEDS_COMMENT;
90+DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
91 #include <soft-fp.h>
92 #include <single.h>
93 #include <double.h>
94@@ -53,4 +63,6 @@ __fdiv (double x, double y)
95 CHECK_NARROW_DIV (ret, x, y);
96 return ret;
97 }
98+DIAG_POP_NEEDS_COMMENT;
99+
100 libm_alias_float_double (div)