[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
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: [hatari-devel] Strange code in softfloat.c (was: patch: Add some missing include directives)
- From: Thomas Huth <th.huth@xxxxxxxxx>
- Date: Sun, 3 May 2020 14:39:50 +0200
- Cc: Toni Wilen <twilen@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1588509593; bh=SmSAQArkPpftES3CIvl/Bv64f2EFmBAkiiRzMwD8UEw=; h=Date:From:To:Cc:Subject:From; b=U9VU0s+np/dGLlwQSFXcx5cAsOyGzCWXhDWJaw18N60/fHdykw2iOldyLJ+eFlrIS vTB4uo7jshjs2wknMAQXuSi3TmO/cSBZ5KgeMtvlS5qdByfYpIrcRDVUNT9qXHSvmu LMmzXmWmZGRYN44vU+B5ojhDRZAjynXEQsdAjHuzmDxwcL8bTzqrStW4seA1ECoetO OxIxxgxqB/VTu4+VmKC9n7Wcp/qQuIDzVXwqBHNHTb6SpG5hpzv/xuxQVRy+39meWp iGIemYzsuQPpeqwMMkI72mWbt6obTIUdP4EsEQA2zyPEd5IV6FwdxeO9HA+3rwcL8/ C/+8ORxBKS4zA==
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