This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix i686-linux-gnu build with GCC mainline [committed]


Building with recent GCC mainline for i686-linux-gnu is failing with:

../sysdeps/ieee754/flt-32/k_rem_pio2f.c: In function '__kernel_rem_pio2f':
../sysdeps/ieee754/flt-32/k_rem_pio2f.c:186:28: error: 'fq[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   fv = math_narrow_eval (fq[0]-fv);
                            ^

and

../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function '__kernel_rem_pio2':
../sysdeps/ieee754/dbl-64/k_rem_pio2.c:333:32: error: 'fq[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       fv = math_narrow_eval (fq[0] - fv);
                                ^

These are similar to -Warray-bounds cases for which the DIAG_* macros
are already used in those files: the array element is in fact always
initialized, but the reasoning that it is depends on another array not
having been all zero at an earlier point, which depends on the
functions not being called with zero arguments.  Thus, this patch uses
DIAG_* to disable -Wmaybe-uninitialized for this code.

(The warning may be i686-specific because of math_narrow_eval somehow
perturbing what the compiler does with this code enough to cause the
warning.  I don't know why it doesn't appear for i686-gnu.)

Tested with build-many-glibcs.py that this fixes the i686 build in
this configuration.  Committed.

2018-05-22  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2): Ignore
	-Wmaybe-uninitialized around access to fq[0].
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
	Likewise.

diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index 820fe77..906792d 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -330,7 +330,16 @@ recompute:
       for (i = jz; i >= 0; i--)
 	fv = math_narrow_eval (fv + fq[i]);
       y[0] = (ih == 0) ? fv : -fv;
+      /* GCC mainline (to be GCC 9), as of 2018-05-22 on i686, warns
+	 that fq[0] may be used uninitialized.  This is not possible
+	 because jz is always nonnegative when the above loop
+	 initializing fq is executed, because the result is never zero
+	 to full precision (this function is not called for zero
+	 arguments).  */
+      DIAG_PUSH_NEEDS_COMMENT;
+      DIAG_IGNORE_NEEDS_COMMENT (9, "-Wmaybe-uninitialized");
       fv = math_narrow_eval (fq[0] - fv);
+      DIAG_POP_NEEDS_COMMENT;
       for (i = 1; i <= jz; i++)
 	fv = math_narrow_eval (fv + fq[i]);
       y[1] = (ih == 0) ? fv : -fv;
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index fdf2b5d..c50e29e 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -183,7 +183,17 @@ recompute:
 		float fv = 0.0;
 		for (i=jz;i>=0;i--) fv = math_narrow_eval (fv + fq[i]);
 		y[0] = (ih==0)? fv: -fv;
+		/* GCC mainline (to be GCC 9), as of 2018-05-22 on
+		   i686, warns that fq[0] may be used uninitialized.
+		   This is not possible because jz is always
+		   nonnegative when the above loop initializing fq is
+		   executed, because the result is never zero to full
+		   precision (this function is not called for zero
+		   arguments).  */
+		DIAG_PUSH_NEEDS_COMMENT;
+		DIAG_IGNORE_NEEDS_COMMENT (9, "-Wmaybe-uninitialized");
 		fv = math_narrow_eval (fq[0]-fv);
+		DIAG_POP_NEEDS_COMMENT;
 		for (i=1;i<=jz;i++) fv = math_narrow_eval (fv + fq[i]);
 		y[1] = (ih==0)? fv: -fv;
 		break;

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]