public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
@ 2016-07-07  8:22 Stefan Liebler
  2016-07-13 10:30 ` Stefan Liebler
  2016-07-20 16:40 ` Joseph Myers
  0 siblings, 2 replies; 12+ messages in thread
From: Stefan Liebler @ 2016-07-07  8:22 UTC (permalink / raw)
  To: libc-alpha; +Cc: Adhemerval Zanella, Joseph S. Myers

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

Hi,

while testing, I've got the following werror on s390x when build with 
gcc 6.1 (or current gcc head) and -O3:
../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function ‘__kernel_rem_pio2’:
../sysdeps/ieee754/dbl-64/k_rem_pio2.c:254:18: error: array subscript is 
below array bounds [-Werror=array-bounds]
     for (k = 1; iq[jk - k] == 0; k++)
                 ~~^~~~~~~~

I get the same error with sysdeps/ieee754/flt-32/k_rem_pio2f.c.

Does anybody else get this warning on another architecture, too?

This patch adds a check so that the index is always >= 0.
Afterwards glibc builds/tests fine with gcc 6.1 and -O3.

Okay to commit?
Before or after release?

Bye
Stefan

ChangeLog:

	* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
	Add test to ensure that array-index is >= 0.
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
	Likewise.

[-- Attachment #2: 20160707_k_rem_pio2_warraybounds.patch --]
[-- Type: text/x-patch, Size: 1105 bytes --]

diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index e58c9e8..4fe14de 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -251,7 +251,7 @@ recompute:
 	j |= iq[i];
       if (j == 0)      /* need recomputation */
 	{
-	  for (k = 1; iq[jk - k] == 0; k++)
+	  for (k = 1; k <= jk && iq[jk - k] == 0; k++)
 	    ;                               /* k = no. of terms needed */
 
 	  for (i = jz + 1; i <= jz + k; i++) /* add q[jz+1] to q[jz+k] */
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index 392afdb..805f487 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -122,7 +122,8 @@ recompute:
 	    j = 0;
 	    for (i=jz-1;i>=jk;i--) j |= iq[i];
 	    if(j==0) { /* need recomputation */
-		for(k=1;iq[jk-k]==0;k++);   /* k = no. of terms needed */
+		for (k = 1; k <= jk && iq[jk - k] == 0; k++)
+		  ;    /* k = no. of terms needed */
 
 		for(i=jz+1;i<=jz+k;i++) {   /* add q[jz+1] to q[jz+k] */
 		    f[jx+i] = (float) ipio2[jv+i];

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-07-07  8:22 [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3 Stefan Liebler
@ 2016-07-13 10:30 ` Stefan Liebler
  2016-07-20 14:10   ` Stefan Liebler
  2016-07-20 16:40 ` Joseph Myers
  1 sibling, 1 reply; 12+ messages in thread
From: Stefan Liebler @ 2016-07-13 10:30 UTC (permalink / raw)
  To: libc-alpha

PING

On 07/07/2016 10:22 AM, Stefan Liebler wrote:
> Hi,
>
> while testing, I've got the following werror on s390x when build with
> gcc 6.1 (or current gcc head) and -O3:
> ../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function ‘__kernel_rem_pio2’:
> ../sysdeps/ieee754/dbl-64/k_rem_pio2.c:254:18: error: array subscript is
> below array bounds [-Werror=array-bounds]
>      for (k = 1; iq[jk - k] == 0; k++)
>                  ~~^~~~~~~~
>
> I get the same error with sysdeps/ieee754/flt-32/k_rem_pio2f.c.
>
> Does anybody else get this warning on another architecture, too?
>
> This patch adds a check so that the index is always >= 0.
> Afterwards glibc builds/tests fine with gcc 6.1 and -O3.
>
> Okay to commit?
> Before or after release?
>
> Bye
> Stefan
>
> ChangeLog:
>
>      * sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
>      Add test to ensure that array-index is >= 0.
>      * sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
>      Likewise.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-07-13 10:30 ` Stefan Liebler
@ 2016-07-20 14:10   ` Stefan Liebler
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Liebler @ 2016-07-20 14:10 UTC (permalink / raw)
  To: libc-alpha

PING

On 07/13/2016 12:25 PM, Stefan Liebler wrote:
> PING
>
> On 07/07/2016 10:22 AM, Stefan Liebler wrote:
>> Hi,
>>
>> while testing, I've got the following werror on s390x when build with
>> gcc 6.1 (or current gcc head) and -O3:
>> ../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function ‘__kernel_rem_pio2’:
>> ../sysdeps/ieee754/dbl-64/k_rem_pio2.c:254:18: error: array subscript is
>> below array bounds [-Werror=array-bounds]
>>      for (k = 1; iq[jk - k] == 0; k++)
>>                  ~~^~~~~~~~
>>
>> I get the same error with sysdeps/ieee754/flt-32/k_rem_pio2f.c.
>>
>> Does anybody else get this warning on another architecture, too?
>>
>> This patch adds a check so that the index is always >= 0.
>> Afterwards glibc builds/tests fine with gcc 6.1 and -O3.
>>
>> Okay to commit?
>> Before or after release?
>>
>> Bye
>> Stefan
>>
>> ChangeLog:
>>
>>      * sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
>>      Add test to ensure that array-index is >= 0.
>>      * sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
>>      Likewise.
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-07-07  8:22 [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3 Stefan Liebler
  2016-07-13 10:30 ` Stefan Liebler
@ 2016-07-20 16:40 ` Joseph Myers
  2016-07-25 16:50   ` Stefan Liebler
  1 sibling, 1 reply; 12+ messages in thread
From: Joseph Myers @ 2016-07-20 16:40 UTC (permalink / raw)
  To: Stefan Liebler; +Cc: libc-alpha, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 916 bytes --]

On Thu, 7 Jul 2016, Stefan Liebler wrote:

> Hi,
> 
> while testing, I've got the following werror on s390x when build with gcc 6.1
> (or current gcc head) and -O3:
> ../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function ‘__kernel_rem_pio2’:
> ../sysdeps/ieee754/dbl-64/k_rem_pio2.c:254:18: error: array subscript is below
> array bounds [-Werror=array-bounds]
>     for (k = 1; iq[jk - k] == 0; k++)
>                 ~~^~~~~~~~
> 
> I get the same error with sysdeps/ieee754/flt-32/k_rem_pio2f.c.
> 
> Does anybody else get this warning on another architecture, too?
> 
> This patch adds a check so that the index is always >= 0.

Such an unnecessary check is not how we deal with bogus warnings.  
Rather, use the DIAG_*_NEEDS_COMMENT macros from include/libc-internal.h, 
with a detailed comment explaining what the warning is and why it is a 
false positive.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-07-20 16:40 ` Joseph Myers
@ 2016-07-25 16:50   ` Stefan Liebler
  2016-08-01 14:12     ` Mike Frysinger
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Liebler @ 2016-07-25 16:50 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

On 07/20/2016 06:33 PM, Joseph Myers wrote:
> On Thu, 7 Jul 2016, Stefan Liebler wrote:
>
>> Hi,
>>
>> while testing, I've got the following werror on s390x when build with gcc 6.1
>> (or current gcc head) and -O3:
>> ../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function ‘__kernel_rem_pio2’:
>> ../sysdeps/ieee754/dbl-64/k_rem_pio2.c:254:18: error: array subscript is below
>> array bounds [-Werror=array-bounds]
>>      for (k = 1; iq[jk - k] == 0; k++)
>>                  ~~^~~~~~~~
>>
>> I get the same error with sysdeps/ieee754/flt-32/k_rem_pio2f.c.
>>
>> Does anybody else get this warning on another architecture, too?
>>
>> This patch adds a check so that the index is always >= 0.
>
> Such an unnecessary check is not how we deal with bogus warnings.
> Rather, use the DIAG_*_NEEDS_COMMENT macros from include/libc-internal.h,
> with a detailed comment explaining what the warning is and why it is a
> false positive.
>

Sorry for the delay. Here is the updated patch with DIAG_* macros.
Is this okay?

Bye Stefan

ChangeLog:


ChangeLog:

	* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
	Use DIAG_*_NEEDS_COMMENT macro to get rid of array-bounds
	warning.
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
	Likewise.

[-- Attachment #2: 20160725_k_rem_pio2_warraybounds.patch --]
[-- Type: text/x-patch, Size: 2412 bytes --]

diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index e58c9e8..4fa05b9 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -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] */
 	    {
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index 392afdb..83d3214 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -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,15 @@ 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];

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-07-25 16:50   ` Stefan Liebler
@ 2016-08-01 14:12     ` Mike Frysinger
  2016-08-02  8:37       ` Stefan Liebler
  0 siblings, 1 reply; 12+ messages in thread
From: Mike Frysinger @ 2016-08-01 14:12 UTC (permalink / raw)
  To: Stefan Liebler; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-08-01 14:12     ` Mike Frysinger
@ 2016-08-02  8:37       ` Stefan Liebler
  2016-08-10 10:08         ` Stefan Liebler
  2016-08-10 11:38         ` Joseph Myers
  0 siblings, 2 replies; 12+ messages in thread
From: Stefan Liebler @ 2016-08-02  8:37 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

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

[-- Attachment #2: 20160802_k_rem_pio2_warraybounds.patch --]
[-- Type: text/x-patch, Size: 2423 bytes --]

diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index e58c9e8..db0a657 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -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] */
 	    {
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index 392afdb..cca20aa 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -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];

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-08-02  8:37       ` Stefan Liebler
@ 2016-08-10 10:08         ` Stefan Liebler
  2016-08-10 11:38         ` Joseph Myers
  1 sibling, 0 replies; 12+ messages in thread
From: Stefan Liebler @ 2016-08-10 10:08 UTC (permalink / raw)
  To: libc-alpha

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-08-02  8:37       ` Stefan Liebler
  2016-08-10 10:08         ` Stefan Liebler
@ 2016-08-10 11:38         ` Joseph Myers
  2016-08-17  8:23           ` Stefan Liebler
  1 sibling, 1 reply; 12+ messages in thread
From: Joseph Myers @ 2016-08-10 11:38 UTC (permalink / raw)
  To: Stefan Liebler; +Cc: libc-alpha

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.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-08-10 11:38         ` Joseph Myers
@ 2016-08-17  8:23           ` Stefan Liebler
  2016-08-17 15:32             ` Joseph Myers
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Liebler @ 2016-08-17  8:23 UTC (permalink / raw)
  To: libc-alpha; +Cc: Joseph S. Myers

[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]

On 08/10/2016 01:38 PM, Joseph Myers wrote:
> 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.
>
I've reviewed the call sequences and adjusted the comment and removed 
the () after the function names.
Here is the updated patch.

Okay to commit?

Bye
Stefan

ChangeLog:

	* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
	Use DIAG_*_NEEDS_COMMENT macro to get rid of array-bounds
	warning.
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
	Likewise.

[-- Attachment #2: 20160817_k_rem_pio2_warraybounds.patch --]
[-- Type: text/x-patch, Size: 2480 bytes --]

diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index e58c9e8..d853b65 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -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,17 @@ 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_pio2 for normal numbers and |x| > pi/4 in case
+	     of ldbl-96 and |x| > 3pi/4 in case of ldbl-128[ibm].
+	     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] */
 	    {
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index 392afdb..52ffb09 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -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];

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-08-17  8:23           ` Stefan Liebler
@ 2016-08-17 15:32             ` Joseph Myers
  2016-08-18 10:42               ` Stefan Liebler
  0 siblings, 1 reply; 12+ messages in thread
From: Joseph Myers @ 2016-08-17 15:32 UTC (permalink / raw)
  To: Stefan Liebler; +Cc: libc-alpha

On Wed, 17 Aug 2016, Stefan Liebler wrote:

> I've reviewed the call sequences and adjusted the comment and removed the ()
> after the function names.
> Here is the updated patch.
> 
> Okay to commit?

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.
  2016-08-17 15:32             ` Joseph Myers
@ 2016-08-18 10:42               ` Stefan Liebler
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Liebler @ 2016-08-18 10:42 UTC (permalink / raw)
  To: libc-alpha

On 08/17/2016 05:32 PM, Joseph Myers wrote:
> On Wed, 17 Aug 2016, Stefan Liebler wrote:
>
>> I've reviewed the call sequences and adjusted the comment and removed the ()
>> after the function names.
>> Here is the updated patch.
>>
>> Okay to commit?
>
> OK.
>
Commited.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-08-18 10:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-07  8:22 [PATCH] Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3 Stefan Liebler
2016-07-13 10:30 ` Stefan Liebler
2016-07-20 14:10   ` Stefan Liebler
2016-07-20 16:40 ` Joseph Myers
2016-07-25 16:50   ` Stefan Liebler
2016-08-01 14:12     ` Mike Frysinger
2016-08-02  8:37       ` Stefan Liebler
2016-08-10 10:08         ` Stefan Liebler
2016-08-10 11:38         ` Joseph Myers
2016-08-17  8:23           ` Stefan Liebler
2016-08-17 15:32             ` Joseph Myers
2016-08-18 10:42               ` Stefan Liebler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).