Fix warnings from latest GCC
Commit Message
I was building the top-of-tree glibc with the top-of-tree GCC and ran into
some new GCC errors.
../sysdeps/ieee754/dbl-64/e_pow.c: In function ‘checkint’:
../sysdeps/ieee754/dbl-64/e_pow.c:469:13: error: << in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]
if (n << (k - 20))
~~^~~~~~~~~~~
../sysdeps/ieee754/dbl-64/e_pow.c:471:17: error: << in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]
return (n << (k - 21)) ? -1 : 1;
~~~^~~~~~~~~~~~
../sysdeps/ieee754/dbl-64/e_pow.c:477:9: error: << in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]
if (m << (k + 12))
~~^~~~~~~~~~~
../sysdeps/ieee754/dbl-64/e_pow.c:479:13: error: << in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]
return (m << (k + 11)) ? -1 : 1;
~~~^~~~~~~~~~~~
cc1: all warnings being treated as errors
The easiest fix seems to be to add explicit '!= 0' to these lines. I did this
and verified that the generated code (on aarch64) is identical.
OK to checkin?
Steve Ellcey
sellcey@caviumnetworks.com (previously sellcey@imgtec.com)
* e_pow.c (checkint) Make conditions explicitly boolean.
Comments
On Mon, 10 Oct 2016, Steve Ellcey wrote:
> The easiest fix seems to be to add explicit '!= 0' to these lines. I did this
> and verified that the generated code (on aarch64) is identical.
>
> OK to checkin?
OK (this accords with the glibc rule that such implicit boolean
conversions should be avoided).
@@ -466,15 +466,15 @@ checkint (double x)
return (n & 1) ? -1 : 1; /* odd or even */
if (k > 20)
{
- if (n << (k - 20))
+ if (n << (k - 20) != 0)
return 0; /* if not integer */
- return (n << (k - 21)) ? -1 : 1;
+ return (n << (k - 21) != 0) ? -1 : 1;
}
if (n)
return 0; /*if not integer */
if (k == 20)
return (m & 1) ? -1 : 1;
- if (m << (k + 12))
+ if (m << (k + 12) != 0)
return 0;
- return (m << (k + 11)) ? -1 : 1;
+ return (m << (k + 11) != 0) ? -1 : 1;
}