Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
Commit Message
On 08/01/2016 04:12 PM, Mike Frysinger wrote:
> On 25 Jul 2016 17:55, Stefan Liebler wrote:
>> + /* On s390x gcc 6.1 -O3 produces the warning "array subscript is below
>> + array bounds [-Werror=array-bounds]". Only __ieee754_rem_pio2l()
>> + calls __kernel_rem_pio2f() for normal numbers and |x| > 3pi/4. Thus
>> + x can't be zero and ipio2 is not zero, too. Thus not all iq[]
>> + values can't be zero. */
>
> GNU style puts two spaces after the period
> -mike
>
Oops. I missed that.
Here is an update.
Thanks.
Stefan
Comments
PING
On 08/02/2016 10:37 AM, Stefan Liebler wrote:
> On 08/01/2016 04:12 PM, Mike Frysinger wrote:
>> On 25 Jul 2016 17:55, Stefan Liebler wrote:
>>> + /* On s390x gcc 6.1 -O3 produces the warning "array subscript
>>> is below
>>> + array bounds [-Werror=array-bounds]". Only
>>> __ieee754_rem_pio2l()
>>> + calls __kernel_rem_pio2f() for normal numbers and |x| >
>>> 3pi/4. Thus
>>> + x can't be zero and ipio2 is not zero, too. Thus not all iq[]
>>> + values can't be zero. */
>>
>> GNU style puts two spaces after the period
>> -mike
>>
> Oops. I missed that.
> Here is an update.
> Thanks.
> Stefan
On Tue, 2 Aug 2016, Stefan Liebler wrote:
> diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
> + /* On s390x gcc 6.1 -O3 produces the warning "array subscript is below
> + array bounds [-Werror=array-bounds]". Only __ieee754_rem_pio2l()
> + calls __kernel_rem_pio2f() for normal numbers and |x| > 3pi/4.
__kernel_rem_pio2f seems like the wrong function to reference in a comment
in this file. Please review the actual call sequences in each case to
make sure the right functions are referenced. Also, the GNU Coding
Standards say not to use () after a function name when referencing the
function:
Please do not write @samp{()} after a function name just to indicate
it is a function. @code{foo ()} is not a function, it is a function
call with no arguments.
> + /* On s390x gcc 6.1 -O3 produces the warning "array subscript is
> + below array bounds [-Werror=array-bounds]". Only
> + __ieee754_rem_pio2f() calls __kernel_rem_pio2f() for normal
Likewise, don't use () after the function name.
@@ -132,6 +132,7 @@ static char rcsid[] = "$NetBSD: k_rem_pio2.c,v 1.7 1995/05/10 20:46:25 jtc Exp $
#include <math.h>
#include <math_private.h>
+#include <libc-internal.h>
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
@@ -251,8 +252,16 @@ recompute:
j |= iq[i];
if (j == 0) /* need recomputation */
{
+ /* On s390x gcc 6.1 -O3 produces the warning "array subscript is below
+ array bounds [-Werror=array-bounds]". Only __ieee754_rem_pio2l()
+ calls __kernel_rem_pio2f() for normal numbers and |x| > 3pi/4.
+ Thus x can't be zero and ipio2 is not zero, too. Thus not all iq[]
+ values can't be zero. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (6.1, "-Warray-bounds");
for (k = 1; iq[jk - k] == 0; k++)
; /* k = no. of terms needed */
+ DIAG_POP_NEEDS_COMMENT;
for (i = jz + 1; i <= jz + k; i++) /* add q[jz+1] to q[jz+k] */
{
@@ -19,6 +19,7 @@ static char rcsid[] = "$NetBSD: k_rem_pio2f.c,v 1.4 1995/05/10 20:46:28 jtc Exp
#include <math.h>
#include <math_private.h>
+#include <libc-internal.h>
/* In the float version, the input parameter x contains 8 bit
integers, not 24 bit integers. 113 bit precision is not supported. */
@@ -122,7 +123,16 @@ recompute:
j = 0;
for (i=jz-1;i>=jk;i--) j |= iq[i];
if(j==0) { /* need recomputation */
+ /* On s390x gcc 6.1 -O3 produces the warning "array subscript is
+ below array bounds [-Werror=array-bounds]". Only
+ __ieee754_rem_pio2f() calls __kernel_rem_pio2f() for normal
+ numbers and |x| ~> 2^7*(pi/2). Thus x can't be zero and
+ ipio2 is not zero, too. Thus not all iq[] values can't be
+ zero. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (6.1, "-Warray-bounds");
for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */
+ DIAG_POP_NEEDS_COMMENT;
for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */
f[jx+i] = (float) ipio2[jv+i];