string/stratcliff.c: Replace int with size_t [BZ #21982]

Message ID 20170820171713.GA19531@gmail.com
State New, archived
Headers

Commit Message

H.J. Lu Aug. 20, 2017, 5:17 p.m. UTC
  Fix GCC 7 errors when string/stratcliff.c is compiled with -O3:

stratcliff.c: In function ‘do_test’:
cc1: error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow]

OK for master?

H.J.
---
	[BZ #21982]
	* string/stratcliff.c (do_test): Declare size, nchars, inner,
	middle and outer with size_t instead of int.  Repleace %d with
	%Zd in printf.
---
 string/stratcliff.c | 72 ++++++++++++++++++++++++++---------------------------
 1 file changed, 36 insertions(+), 36 deletions(-)
  

Comments

Joseph Myers Aug. 21, 2017, 1:23 p.m. UTC | #1
On Sun, 20 Aug 2017, H.J. Lu wrote:

> @@ -101,7 +101,7 @@ do_test (void)
>  
>  	      if (STRLEN (&adr[outer]) != (size_t) (inner - outer))
>  		{
> -		  printf ("%s flunked for outer = %d, inner = %d\n",
> +		  printf ("%s flunked for outer = %Zd, inner = %Zd\n",

I don't think we should be using legacy %Z in any new code.  Use C99 %zu 
for size_t (%zd only if the argument is the corresponding signed type 
rather than size_t itself).
  
Stefan Liebler Aug. 21, 2017, 1:48 p.m. UTC | #2
On 08/20/2017 07:17 PM, H.J. Lu wrote:
> Fix GCC 7 errors when string/stratcliff.c is compiled with -O3:
> 
> stratcliff.c: In function ‘do_test’:
> cc1: error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow]
> 
> OK for master?
> 
> H.J.
> ---
> 	[BZ #21982]
> 	* string/stratcliff.c (do_test): Declare size, nchars, inner,
> 	middle and outer with size_t instead of int.  Repleace %d with
> 	%Zd in printf.
> ---
>   string/stratcliff.c | 72 ++++++++++++++++++++++++++---------------------------
>   1 file changed, 36 insertions(+), 36 deletions(-)
> 
> diff --git a/string/stratcliff.c b/string/stratcliff.c
> index e28b0c5058..ae780379cb 100644
> --- a/string/stratcliff.c
> +++ b/string/stratcliff.c
> @@ -58,8 +58,8 @@
>   int
>   do_test (void)
>   {
> -  int size = sysconf (_SC_PAGESIZE);
> -  int nchars = size / sizeof (CHAR);
> +  size_t size = sysconf (_SC_PAGESIZE);
> +  size_t nchars = size / sizeof (CHAR);
>     CHAR *adr;
>     CHAR *dest;
>     int result = 0;
> @@ -80,7 +80,7 @@ do_test (void)
>       }
>     else
>       {
> -      int inner, middle, outer;
> +      size_t inner, middle, outer;
> 
>         mprotect (adr, size, PROT_NONE);
>         mprotect (adr + 2 * nchars, size, PROT_NONE);
> @@ -101,7 +101,7 @@ do_test (void)
> 
>   	      if (STRLEN (&adr[outer]) != (size_t) (inner - outer))
>   		{
> -		  printf ("%s flunked for outer = %d, inner = %d\n",
> +		  printf ("%s flunked for outer = %Zd, inner = %Zd\n",
>   			  STRINGIFY (STRLEN), outer, inner);
>   		  result = 1;
>   		}
>   		{
> -		  printf ("%s flunked for outer = %d, middle = %d\n",
> +		  printf ("%s flunked for outer = %Zd, middle = %Zd\n",
>   			  STRINGIFY (rawmemchr), outer, middle);
>   		  result = 1;
>   		}
> Hi H.J. Lu,

I've applied your patch and the warnings does not occur anymore on s390.

The outer loops of the string tests are all using the following:
size_t nchars, outer;
for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)

I think we can assume, that nchars is always > 128 as it is derived by 
the pagesize.
But if nchars would be equal to 128, this would result in an infinite 
loop (outer >= 0)?
If nchars would be less than 128, the tests would be skipped.

Should we add a check that nchars > 128 at the beginning and replace the 
"MAX (0, nchars - 128)" with only "nchars - 128"?

Bye,
Stefan
  
H.J. Lu Aug. 21, 2017, 1:51 p.m. UTC | #3
On Mon, Aug 21, 2017 at 6:23 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Sun, 20 Aug 2017, H.J. Lu wrote:
>
>> @@ -101,7 +101,7 @@ do_test (void)
>>
>>             if (STRLEN (&adr[outer]) != (size_t) (inner - outer))
>>               {
>> -               printf ("%s flunked for outer = %d, inner = %d\n",
>> +               printf ("%s flunked for outer = %Zd, inner = %Zd\n",
>
> I don't think we should be using legacy %Z in any new code.  Use C99 %zu
> for size_t (%zd only if the argument is the corresponding signed type
> rather than size_t itself).
>

There are some %Zd in string/stratcliff.c.  Should they be changed?
Since All of them are size_t, I will replace %Zd with %zu.
  
Joseph Myers Aug. 21, 2017, 1:55 p.m. UTC | #4
On Mon, 21 Aug 2017, H.J. Lu wrote:

> On Mon, Aug 21, 2017 at 6:23 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> > On Sun, 20 Aug 2017, H.J. Lu wrote:
> >
> >> @@ -101,7 +101,7 @@ do_test (void)
> >>
> >>             if (STRLEN (&adr[outer]) != (size_t) (inner - outer))
> >>               {
> >> -               printf ("%s flunked for outer = %d, inner = %d\n",
> >> +               printf ("%s flunked for outer = %Zd, inner = %Zd\n",
> >
> > I don't think we should be using legacy %Z in any new code.  Use C99 %zu
> > for size_t (%zd only if the argument is the corresponding signed type
> > rather than size_t itself).
> >
> 
> There are some %Zd in string/stratcliff.c.  Should they be changed?
> Since All of them are size_t, I will replace %Zd with %zu.

In my view it makes sense to clean up existing uses of %Z legacy formats, 
provided there is still stdio test coverage that %Z behaves as expected.
  
H.J. Lu Aug. 21, 2017, 2:53 p.m. UTC | #5
On Mon, Aug 21, 2017 at 6:48 AM, Stefan Liebler <stli@linux.vnet.ibm.com> wrote:
> On 08/20/2017 07:17 PM, H.J. Lu wrote:
>>
>> Fix GCC 7 errors when string/stratcliff.c is compiled with -O3:
>>
>> stratcliff.c: In function ‘do_test’:
>> cc1: error: assuming signed overflow does not occur when assuming that (X
>> - c) <= X is always true [-Werror=strict-overflow]
>>
>> OK for master?
>>
>> H.J.
>> ---
>>         [BZ #21982]
>>         * string/stratcliff.c (do_test): Declare size, nchars, inner,
>>         middle and outer with size_t instead of int.  Repleace %d with
>>         %Zd in printf.
>> ---
>>   string/stratcliff.c | 72
>> ++++++++++++++++++++++++++---------------------------
>>   1 file changed, 36 insertions(+), 36 deletions(-)
>>
>> diff --git a/string/stratcliff.c b/string/stratcliff.c
>> index e28b0c5058..ae780379cb 100644
>> --- a/string/stratcliff.c
>> +++ b/string/stratcliff.c
>> @@ -58,8 +58,8 @@
>>   int
>>   do_test (void)
>>   {
>> -  int size = sysconf (_SC_PAGESIZE);
>> -  int nchars = size / sizeof (CHAR);
>> +  size_t size = sysconf (_SC_PAGESIZE);
>> +  size_t nchars = size / sizeof (CHAR);
>>     CHAR *adr;
>>     CHAR *dest;
>>     int result = 0;
>> @@ -80,7 +80,7 @@ do_test (void)
>>       }
>>     else
>>       {
>> -      int inner, middle, outer;
>> +      size_t inner, middle, outer;
>>
>>         mprotect (adr, size, PROT_NONE);
>>         mprotect (adr + 2 * nchars, size, PROT_NONE);
>> @@ -101,7 +101,7 @@ do_test (void)
>>
>>               if (STRLEN (&adr[outer]) != (size_t) (inner - outer))
>>                 {
>> -                 printf ("%s flunked for outer = %d, inner = %d\n",
>> +                 printf ("%s flunked for outer = %Zd, inner = %Zd\n",
>>                           STRINGIFY (STRLEN), outer, inner);
>>                   result = 1;
>>                 }
>>                 {
>> -                 printf ("%s flunked for outer = %d, middle = %d\n",
>> +                 printf ("%s flunked for outer = %Zd, middle = %Zd\n",
>>                           STRINGIFY (rawmemchr), outer, middle);
>>                   result = 1;
>>                 }
>> Hi H.J. Lu,
>
>
> I've applied your patch and the warnings does not occur anymore on s390.

Great.

> The outer loops of the string tests are all using the following:
> size_t nchars, outer;
> for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
>
> I think we can assume, that nchars is always > 128 as it is derived by the
> pagesize.
> But if nchars would be equal to 128, this would result in an infinite loop
> (outer >= 0)?
> If nchars would be less than 128, the tests would be skipped.
>
> Should we add a check that nchars > 128 at the beginning and replace the
> "MAX (0, nchars - 128)" with only "nchars - 128"?

This is a separate issue beyond BZ #21982.
  
Stefan Liebler Aug. 21, 2017, 3:41 p.m. UTC | #6
On 08/21/2017 04:53 PM, H.J. Lu wrote:
> On Mon, Aug 21, 2017 at 6:48 AM, Stefan Liebler <stli@linux.vnet.ibm.com> wrote:
>> On 08/20/2017 07:17 PM, H.J. Lu wrote:
>>>
>>> Fix GCC 7 errors when string/stratcliff.c is compiled with -O3:
>>>
>>> stratcliff.c: In function ‘do_test’:
>>> cc1: error: assuming signed overflow does not occur when assuming that (X
>>> - c) <= X is always true [-Werror=strict-overflow]
>>>
>>> OK for master?
>>>
>>> H.J.
>>> ---
>>>          [BZ #21982]
>>>          * string/stratcliff.c (do_test): Declare size, nchars, inner,
>>>          middle and outer with size_t instead of int.  Repleace %d with
>>>          %Zd in printf.
>>> ---
>>>    string/stratcliff.c | 72
>>> ++++++++++++++++++++++++++---------------------------
>>>    1 file changed, 36 insertions(+), 36 deletions(-)
>>>
>>> diff --git a/string/stratcliff.c b/string/stratcliff.c
>>> index e28b0c5058..ae780379cb 100644
>>> --- a/string/stratcliff.c
>>> +++ b/string/stratcliff.c
>>> @@ -58,8 +58,8 @@
>>>    int
>>>    do_test (void)
>>>    {
>>> -  int size = sysconf (_SC_PAGESIZE);
>>> -  int nchars = size / sizeof (CHAR);
>>> +  size_t size = sysconf (_SC_PAGESIZE);
>>> +  size_t nchars = size / sizeof (CHAR);
>>>      CHAR *adr;
>>>      CHAR *dest;
>>>      int result = 0;
>>> @@ -80,7 +80,7 @@ do_test (void)
>>>        }
>>>      else
>>>        {
>>> -      int inner, middle, outer;
>>> +      size_t inner, middle, outer;
>>>
>>>          mprotect (adr, size, PROT_NONE);
>>>          mprotect (adr + 2 * nchars, size, PROT_NONE);
>>> @@ -101,7 +101,7 @@ do_test (void)
>>>
>>>                if (STRLEN (&adr[outer]) != (size_t) (inner - outer))
>>>                  {
>>> -                 printf ("%s flunked for outer = %d, inner = %d\n",
>>> +                 printf ("%s flunked for outer = %Zd, inner = %Zd\n",
>>>                            STRINGIFY (STRLEN), outer, inner);
>>>                    result = 1;
>>>                  }
>>>                  {
>>> -                 printf ("%s flunked for outer = %d, middle = %d\n",
>>> +                 printf ("%s flunked for outer = %Zd, middle = %Zd\n",
>>>                            STRINGIFY (rawmemchr), outer, middle);
>>>                    result = 1;
>>>                  }
>>> Hi H.J. Lu,
>>
>>
>> I've applied your patch and the warnings does not occur anymore on s390.
> 
> Great.
> 
>> The outer loops of the string tests are all using the following:
>> size_t nchars, outer;
>> for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
>>
>> I think we can assume, that nchars is always > 128 as it is derived by the
>> pagesize.
>> But if nchars would be equal to 128, this would result in an infinite loop
>> (outer >= 0)?
>> If nchars would be less than 128, the tests would be skipped.
>>
>> Should we add a check that nchars > 128 at the beginning and replace the
>> "MAX (0, nchars - 128)" with only "nchars - 128"?
> 
> This is a separate issue beyond BZ #21982.
> 
> 
Your patch is introducing this behaviour.
Before your patch, nchars and outer was an int and the 
for-loop-condition "outer >= MAX (0, nchars - 128)" does not lead to an 
infinite loop or to skipping the test if nchars <= 128.
  

Patch

diff --git a/string/stratcliff.c b/string/stratcliff.c
index e28b0c5058..ae780379cb 100644
--- a/string/stratcliff.c
+++ b/string/stratcliff.c
@@ -58,8 +58,8 @@ 
 int
 do_test (void)
 {
-  int size = sysconf (_SC_PAGESIZE);
-  int nchars = size / sizeof (CHAR);
+  size_t size = sysconf (_SC_PAGESIZE);
+  size_t nchars = size / sizeof (CHAR);
   CHAR *adr;
   CHAR *dest;
   int result = 0;
@@ -80,7 +80,7 @@  do_test (void)
     }
   else
     {
-      int inner, middle, outer;
+      size_t inner, middle, outer;
 
       mprotect (adr, size, PROT_NONE);
       mprotect (adr + 2 * nchars, size, PROT_NONE);
@@ -101,7 +101,7 @@  do_test (void)
 
 	      if (STRLEN (&adr[outer]) != (size_t) (inner - outer))
 		{
-		  printf ("%s flunked for outer = %d, inner = %d\n",
+		  printf ("%s flunked for outer = %Zd, inner = %Zd\n",
 			  STRINGIFY (STRLEN), outer, inner);
 		  result = 1;
 		}
@@ -120,7 +120,7 @@  do_test (void)
 	      if (STRNLEN (&adr[outer], inner - outer + 1)
 		  != (size_t) (inner - outer))
 		{
-		  printf ("%s flunked for outer = %d, inner = %d\n",
+		  printf ("%s flunked for outer = %Zd, inner = %Zd\n",
 			  STRINGIFY (STRNLEN), outer, inner);
 		  result = 1;
 		}
@@ -135,7 +135,7 @@  do_test (void)
 	      if (STRNLEN (&adr[outer], inner - outer)
 		  != (size_t) (inner - outer))
 		{
-		  printf ("%s flunked bounded for outer = %d, inner = %d\n",
+		  printf ("%s flunked bounded for outer = %Zd, inner = %Zd\n",
 			  STRINGIFY (STRNLEN), outer, inner);
 		  result = 1;
 		}
@@ -158,8 +158,8 @@  do_test (void)
 		      || (inner != middle
 			  && (cp - &adr[outer]) != middle - outer))
 		    {
-		      printf ("%s flunked for outer = %d, middle = %d, "
-			      "inner = %d\n",
+		      printf ("%s flunked for outer = %Zd, middle = %Zd, "
+			      "inner = %Zd\n",
 			      STRINGIFY (STRCHR), outer, middle, inner);
 		      result = 1;
 		    }
@@ -195,8 +195,8 @@  do_test (void)
 		      || (inner != middle
 			  && (cp - &adr[outer]) != middle - outer))
 		    {
-		      printf ("%s flunked for outer = %d, middle = %d, "
-			      "inner = %d\n",
+		      printf ("%s flunked for outer = %Zd, middle = %Zd, "
+			      "inner = %Zd\n",
 			      STRINGIFY (STRRCHR), outer, middle, inner);
 		      result = 1;
 		    }
@@ -218,7 +218,7 @@  do_test (void)
 
 	      if (cp - &adr[outer] != middle - outer)
 		{
-		  printf ("%s flunked for outer = %d, middle = %d\n",
+		  printf ("%s flunked for outer = %Zd, middle = %Zd\n",
 			  STRINGIFY (MEMCHR), outer, middle);
 		  result = 1;
 		}
@@ -232,7 +232,7 @@  do_test (void)
 
 	  if (cp != NULL)
 	    {
-	      printf ("%s flunked for outer = %d\n",
+	      printf ("%s flunked for outer = %Zd\n",
 		      STRINGIFY (MEMCHR), outer);
 	      result = 1;
 	    }
@@ -251,7 +251,7 @@  do_test (void)
 
 	      if (cp - &adr[outer] != middle - outer)
 		{
-		  printf ("%s flunked for outer = %d, middle = %d\n",
+		  printf ("%s flunked for outer = %Zd, middle = %Zd\n",
 			  STRINGIFY (rawmemchr), outer, middle);
 		  result = 1;
 		}
@@ -271,7 +271,7 @@  do_test (void)
 
 	      if (cp - &adr[outer] != middle - outer)
 		{
-		  printf ("%s flunked for outer = %d, middle = %d\n",
+		  printf ("%s flunked for outer = %Zd, middle = %Zd\n",
 			  STRINGIFY (memrchr), outer, middle);
 		  result = 1;
 		}
@@ -285,7 +285,7 @@  do_test (void)
 
 	  if (cp != NULL)
 	    {
-	      printf ("%s flunked for outer = %d\n",
+	      printf ("%s flunked for outer = %Zd\n",
 		      STRINGIFY (memrchr), outer);
 	      result = 1;
 	    }
@@ -302,7 +302,7 @@  do_test (void)
 	      if (STRCPY (dest, &adr[outer]) != dest
 		  || STRLEN (dest) != (size_t) (inner - outer))
 		{
-		  printf ("%s flunked for outer = %d, inner = %d\n",
+		  printf ("%s flunked for outer = %Zd, inner = %Zd\n",
 			  STRINGIFY (STRCPY), outer, inner);
 		  result = 1;
 		}
@@ -322,14 +322,14 @@  do_test (void)
 
 	    if (STRCMP (adr + middle, dest + nchars - outer) <= 0)
 	      {
-		printf ("%s 1 flunked for outer = %d, middle = %d\n",
+		printf ("%s 1 flunked for outer = %Zd, middle = %Zd\n",
 			STRINGIFY (STRCMP), outer, middle);
 		result = 1;
 	      }
 
 	    if (STRCMP (dest + nchars - outer, adr + middle) >= 0)
 	      {
-		printf ("%s 2 flunked for outer = %d, middle = %d\n",
+		printf ("%s 2 flunked for outer = %Zd, middle = %Zd\n",
 			STRINGIFY (STRCMP), outer, middle);
 		result = 1;
 	      }
@@ -348,16 +348,16 @@  do_test (void)
 	      {
 		if (STRNCMP (adr + middle, dest + nchars - outer, inner) != 0)
 		  {
-		    printf ("%s 1 flunked for outer = %d, middle = %d, "
-			    "inner = %d\n",
+		    printf ("%s 1 flunked for outer = %Zd, middle = %Zd, "
+			    "inner = %Zd\n",
 			    STRINGIFY (STRNCMP), outer, middle, inner);
 		    result = 1;
 		  }
 
 		if (STRNCMP (dest + nchars - outer, adr + middle, inner) != 0)
 		  {
-		    printf ("%s 2 flunked for outer = %d, middle = %d, "
-			    "inner = %d\n",
+		    printf ("%s 2 flunked for outer = %Zd, middle = %Zd, "
+			    "inner = %Zd\n",
 			    STRINGIFY (STRNCMP), outer, middle, inner);
 		    result = 1;
 		  }
@@ -365,14 +365,14 @@  do_test (void)
 
 	    if (STRNCMP (adr + middle, dest + nchars - outer, outer) >= 0)
 	      {
-		printf ("%s 1 flunked for outer = %d, middle = %d, full\n",
+		printf ("%s 1 flunked for outer = %Zd, middle = %Zd, full\n",
 			STRINGIFY (STRNCMP), outer, middle);
 		result = 1;
 	      }
 
 	    if (STRNCMP (dest + nchars - outer, adr + middle, outer) <= 0)
 	      {
-		printf ("%s 2 flunked for outer = %d, middle = %d, full\n",
+		printf ("%s 2 flunked for outer = %Zd, middle = %Zd, full\n",
 			STRINGIFY (STRNCMP), outer, middle);
 		result = 1;
 	      }
@@ -389,7 +389,7 @@  do_test (void)
 	      if (STRNCPY (dest, &adr[outer], len) != dest
 		  || MEMCMP (dest, &adr[outer], len) != 0)
 		{
-		  printf ("outer %s flunked for outer = %d, len = %Zd\n",
+		  printf ("outer %s flunked for outer = %Zd, len = %Zd\n",
 			  STRINGIFY (STRNCPY), outer, len);
 		  result = 1;
 		}
@@ -413,7 +413,7 @@  do_test (void)
 		      || (inner - outer < len
 			  && STRLEN (dest) != (inner - outer)))
 		    {
-		      printf ("%s flunked for outer = %d, inner = %d, "
+		      printf ("%s flunked for outer = %Zd, inner = %Zd, "
 			      "len = %Zd\n",
 			      STRINGIFY (STRNCPY), outer, inner, len);
 		      result = 1;
@@ -424,7 +424,7 @@  do_test (void)
 		      || (inner - outer < len
 			  && STRLEN (dest + 1) != (inner - outer)))
 		    {
-		      printf ("%s+1 flunked for outer = %d, inner = %d, "
+		      printf ("%s+1 flunked for outer = %Zd, inner = %Zd, "
 			      "len = %Zd\n",
 			      STRINGIFY (STRNCPY), outer, inner, len);
 		      result = 1;
@@ -444,7 +444,7 @@  do_test (void)
 
 	      if ((STPCPY (dest, &adr[outer]) - dest) != inner - outer)
 		{
-		  printf ("%s flunked for outer = %d, inner = %d\n",
+		  printf ("%s flunked for outer = %Zd, inner = %Zd\n",
 			  STRINGIFY (STPCPY), outer, inner);
 		  result = 1;
 		}
@@ -464,7 +464,7 @@  do_test (void)
 	      if (STPNCPY (dest, &adr[outer], len) != dest + len
 		  || MEMCMP (dest, &adr[outer], len) != 0)
 		{
-		  printf ("outer %s flunked for outer = %d, len = %Zd\n",
+		  printf ("outer %s flunked for outer = %Zd, len = %Zd\n",
 			  STRINGIFY (STPNCPY), outer, len);
 		  result = 1;
 		}
@@ -483,8 +483,8 @@  do_test (void)
 		  if ((STPNCPY (dest, &adr[outer], inner) - dest)
 		      != MIN (inner, middle - outer))
 		    {
-		      printf ("%s flunked for outer = %d, middle = %d, "
-			      "inner = %d\n",
+		      printf ("%s flunked for outer = %Zd, middle = %Zd, "
+			      "inner = %Zd\n",
 			      STRINGIFY (STPNCPY), outer, middle, inner);
 		      result = 1;
 		    }
@@ -499,7 +499,7 @@  do_test (void)
 	for (inner = 0; inner < nchars - outer; ++inner)
 	  if (MEMCPY (dest, &adr[outer], inner) !=  dest)
 	    {
-	      printf ("%s flunked for outer = %d, inner = %d\n",
+	      printf ("%s flunked for outer = %Zd, inner = %Zd\n",
 		      STRINGIFY (MEMCPY), outer, inner);
 	      result = 1;
 	    }
@@ -509,7 +509,7 @@  do_test (void)
 	for (inner = 0; inner < nchars - outer; ++inner)
 	  if (MEMPCPY (dest, &adr[outer], inner) !=  dest + inner)
 	    {
-	      printf ("%s flunked for outer = %d, inner = %d\n",
+	      printf ("%s flunked for outer = %Zd, inner = %Zd\n",
 		      STRINGIFY (MEMPCPY), outer, inner);
 	      result = 1;
 	    }
@@ -522,7 +522,7 @@  do_test (void)
 	for (inner = 0; inner < nchars - outer; ++inner)
 	  if (memccpy (dest, &adr[outer], L('\1'), inner) != NULL)
 	    {
-	      printf ("memccpy flunked full copy for outer = %d, inner = %d\n",
+	      printf ("memccpy flunked full copy for outer = %Zd, inner = %Zd\n",
 		      outer, inner);
 	      result = 1;
 	    }
@@ -538,14 +538,14 @@  do_test (void)
 		    !=  dest + inner + 1)
 		  {
 		    printf ("\
-memccpy flunked partial copy for outer = %d, middle = %d, inner = %d\n",
+memccpy flunked partial copy for outer = %Zd, middle = %Zd, inner = %Zd\n",
 			    outer, middle, inner);
 		    result = 1;
 		  }
 		else if (dest[inner + 1] != L('\2'))
 		  {
 		    printf ("\
-memccpy copied too much for outer = %d, middle = %d, inner = %d\n",
+memccpy copied too much for outer = %Zd, middle = %Zd, inner = %Zd\n",
 			    outer, middle, inner);
 		    result = 1;
 		  }