Re: [hatari-devel] Strange code in softfloat.c (was: patch: Add some missing include directives)

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Am Sun, 3 May 2020 18:29:00 +0300
schrieb Toni Wilen <twilen@xxxxxxxxxx>:

> > After updating my system to Fedora 32, I now get the same warnings
> > with Clang version 10:
> > 
> > src/cpu/softfloat/softfloat.c:181:22: warning: bitwise negation of
> > a boolean expression; did you mean logical negation?
> > [-Wbool-operation] zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) &
> > ( status->float_rounding_mode == float_round_nearest_even ) );
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > ! src/cpu/softfloat/softfloat.c:300:22: warning: bitwise negation
> > of a boolean expression; did you mean logical negation?
> > [-Wbool-operation] zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) &
> > ( floatx80_internal_mode == float_round_nearest_even ) );
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > ! 2 warnings generated. [ 61%] Building C object
> > src/cpu/CMakeFiles/UaeCpu.dir/softfloat/softfloat_decimal.c.o
> > src/cpu/softfloat/softfloat_decimal.c:58:13: warning: bitwise
> > negation of a boolean expression; did you mean logical negation?
> > [-Wbool-operation] zSig0 &= ~ (((uint64_t) (zSig1<<1) == 0) &
> > (status->float_rounding_mode == float_round_nearest_even));
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > ! 1 warning generated.
> > 
> > Toni, any ideas whether this could maybe be done in a different
> > way?  
> 
> What about something simple (and much more readable) like this:
> 
>             if ((zSig1 << 1) == 0 && status->float_rounding_mode ==
> float_round_nearest_even)
>                 zSig0 &= ~1;

Yes, that looks easier to read, indeed, and should silence the compiler
warning. Thanks!

 Thomas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/