[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 Thu, 05 Dec 2019 19:13:32 +0100
schrieb Thorsten Otto <admin@xxxxxxxxxxx>:

> On Mittwoch, 4. Dezember 2019 03:39:56 CET Thorsten Otto wrote:
> > The clang compiler used there also spits out several warnings  
> 
> Some of these warnings look like there is really something wrong
> there:
> 
> /home/sebilla/atari/hatari/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 ) );   
>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
>                     ! 
>                                                                                                                                                                                                              
> /home/sebilla/atari/hatari/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 ) ); 
>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
>                     ! 
>                                                                                                                                                                                                              
> [ 57%] Building C object src/cpu/CMakeFiles/UaeCpu.dir/softfloat/
> softfloat_decimal.c.o 
>                                                                                                                                              
> 2 warnings generated. 
> [ 58%] Building C object src/cpu/CMakeFiles/UaeCpu.dir/softfloat/
> softfloat_fpsp.c.o 
> /home/sebilla/atari/hatari/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));   
>                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
>                                 ! 
>                                                                                                                                                                                                 
> Remember that gcc in c99 mode implements a real bool type like in
> C++, and ~((bool)0) will result in 1, not a bitmask of all ones like
> seems to be intended by above code. Even without c99, the type of the
> expression will be int, and ~(0) will result in 0xffffffff, not
> (uint64_t)-1

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?

 Thomas



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