[glibc] Fix -Werror=constant-logical-operand errors in soft-fp

Joseph Myers via Glibc-cvs <[email protected]> Wed, 10 Jun 2026 16:33:52 +0000 (GMT)
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d8fa402f5edf74b74ef9992b738dce96527e0957

commit d8fa402f5edf74b74ef9992b738dce96527e0957
Author: Joseph Myers <[email protected]>
Date:   Wed Jun 10 16:33:27 2026 +0000

    Fix -Werror=constant-logical-operand errors in soft-fp
    
    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:
---
 soft-fp/op-common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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) \
 	    {								\