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

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Jun 10 16:12:47 GMT 2026



On 10/06/26 12:17, Joseph Myers wrote:
> 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.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

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



More information about the Libc-alpha mailing list