Fix -Werror=constant-logical-operand errors in soft-fp

Joseph Myers josmyers@redhat.com
Wed Jun 10 15:17:22 GMT 2026


Building for sparc64-linux-gnu with GCC mainline produces a series of
-Werror=constant-logical-operand errors in soft-fp code, relating to
calls to _FP_TO_INT where rsigned is -1 not 0 or 1.  Use explicit != 0
in the soft-fp code to avoid these errors.

Tested with build-many-glibcs.py (compilers and glibcs builds) for
sparc64-linux-gnu with GCC mainline.

diff --git a/soft-fp/op-common.h b/soft-fp/op-common.h
index ce8d60ee26..49d47efd32 100644
--- a/soft-fp/op-common.h
+++ b/soft-fp/op-common.h
@@ -1510,7 +1510,7 @@
 	    }								\
 									\
 	  if (_FP_EXPBIAS_##fs + (rsize) - 1 < _FP_EXPMAX_##fs		\
-	      && (rsigned)						\
+	      && (rsigned) != 0						\
 	      && X##_s							\
 	      && X##_e == _FP_EXPBIAS_##fs + (rsize) - 1)		\
 	    {								\
@@ -1555,7 +1555,7 @@
 				  _FP_FRACBITS_##fs);			\
 	      _FP_FRAC_ASSEMBLE_##wc ((r), X, (rsize));			\
 	    }								\
-	  if ((rsigned) && X##_s)					\
+	  if ((rsigned) != 0 && X##_s)					\
 	    (r) = -(r);							\
 	  if ((rsigned) == 2 && X##_e >= _FP_EXPBIAS_##fs + (rsize) - 1) \
 	    {								\

-- 
Joseph S. Myers
josmyers@redhat.com



More information about the Libc-alpha mailing list