Don't use %z printf format length specified

Message ID alpine.LSU.2.21.1811141707370.18790@wotan.suse.de
State New
Headers show
Series
  • Don't use %z printf format length specified
Related show

Commit Message

Michael Matz Nov. 14, 2018, 5:10 p.m.
Hi,

it's not c++98 conforming and I get 1 million warnings when compiling.  
Initially I had also casts to long at the various arguments, but I get no 
warning with this variant either, so I removed them again.  I'm currently 
regstrapping this, okay for trunk if successfull?


Ciao,
Michael.

	* alloc-pool.h (pool_usage::dump): Don't use %z but %l.
	(pool_usage::dump_footer): Likewise.
	* bitmap.h (bitmap_usage::dump): Likewise.
	* ggc-common.c (ggc_usage::dump): Likewise.
	* ggc-page.c (ggc_print_statistics): Likewise.
	* mem-stats.h (mem_usage::dump): Likewise.
	(mem_usage::dump_footer): Likewise.
	* rtl.c (dump_rtx_statistics): Likewise.
	* vec.c (vec_usage::dump): Likewise.
	(vec_usage::dump_footer): Likewise.

Comments

Alexander Monakov Nov. 14, 2018, 5:16 p.m. | #1
On Wed, 14 Nov 2018, Michael Matz wrote:

> Hi,

> 

> it's not c++98 conforming and I get 1 million warnings when compiling.  

> Initially I had also casts to long at the various arguments, but I get no 

> warning with this variant either, so I removed them again.  I'm currently 

> regstrapping this, okay for trunk if successfull?


Surely this will break mingw-w64 where size_t is 64-bit yet long is 32-bit?

Alexander
Andreas Schwab Nov. 14, 2018, 5:20 p.m. | #2
On Nov 14 2018, Michael Matz <matz@suse.de> wrote:

> Initially I had also casts to long at the various arguments, but I get no 

> warning with this variant either, so I removed them again.


That is probably pure luck.  size_t is not required to be the same as
unsigned long.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Michael Matz Nov. 14, 2018, 5:24 p.m. | #3
Hi,

On Wed, 14 Nov 2018, Alexander Monakov wrote:

> On Wed, 14 Nov 2018, Michael Matz wrote:

> 

> > Hi,

> > 

> > it's not c++98 conforming and I get 1 million warnings when compiling.  

> > Initially I had also casts to long at the various arguments, but I get no 

> > warning with this variant either, so I removed them again.  I'm currently 

> > regstrapping this, okay for trunk if successfull?

> 

> Surely this will break mingw-w64 where size_t is 64-bit yet long is 32-bit?


Okay, probably.  Then consider the same patch with sprinkling casts to 
long for all these arguments (the actual numbers will fit that type in 
reality).  I could of course also use PRIu64 but that makes my eyes bleed.


Ciao,
Michael.
Richard Biener Nov. 15, 2018, 10:08 a.m. | #4
On Wed, Nov 14, 2018 at 6:24 PM Michael Matz <matz@suse.de> wrote:
>

> Hi,

>

> On Wed, 14 Nov 2018, Alexander Monakov wrote:

>

> > On Wed, 14 Nov 2018, Michael Matz wrote:

> >

> > > Hi,

> > >

> > > it's not c++98 conforming and I get 1 million warnings when compiling.

> > > Initially I had also casts to long at the various arguments, but I get no

> > > warning with this variant either, so I removed them again.  I'm currently

> > > regstrapping this, okay for trunk if successfull?

> >

> > Surely this will break mingw-w64 where size_t is 64-bit yet long is 32-bit?

>

> Okay, probably.  Then consider the same patch with sprinkling casts to

> long for all these arguments (the actual numbers will fit that type in

> reality).  I could of course also use PRIu64 but that makes my eyes bleed.


Hmm.  Can you use PRIu64 please and cast to uint64_t?  OK with that
change.

Thanks,
Richard.

>

> Ciao,

> Michael.
Michael Matz Nov. 15, 2018, 1:31 p.m. | #5
Hi,

On Thu, 15 Nov 2018, Richard Biener wrote:

> > Okay, probably.  Then consider the same patch with sprinkling casts to 

> > long for all these arguments (the actual numbers will fit that type in 

> > reality).  I could of course also use PRIu64 but that makes my eyes 

> > bleed.

> 

> Hmm.  Can you use PRIu64 please and cast to uint64_t?  OK with that 

> change.


Instead I'd like to check in this.  It adds a new macro expanding to 
  "%" #n PRIu64 "%c"
(with n being the width) corresponding to one SIZE_AMOUNT macro "argument" 
(which are actually two arguments), and hides the cast in the latter macro 
itself.  At least the number of format string args and actual args 
corresponds again then and my eyes bleed a little less.  Still okay?


Ciao,
Michael.

	* system.h (PRsa): New macro.
	(SIZE_AMOUNT): Cast number to uint64_t.
	* alloc-pool.h (pool_usage::dump): Don't use %zu but PRsa.
	(pool_usage::dump_footer): Likewise and also use PRIu64.
	* bitmap.h (bitmap_usage::dump): Likewise.
	* ggc-common.c (ggc_usage::dump): Likewise.
	* ggc-page.c (ggc_print_statistics): Likewise.
	* mem-stats.h (mem_usage::dump): Likewise.
	(mem_usage::dump_footer): Likewise.
	* rtl.c (dump_rtx_statistics): Likewise.
	* vec.c (vec_usage::dump): Likewise.
	(vec_usage::dump_footer): Likewise.

diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index d17a05ca4fb1..81cb69e227ab 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -63,8 +63,8 @@ struct pool_usage: public mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-32s%-48s %5zu%c%9zu%c:%5.1f%%%9zu"
-	     "%c%9zu%c:%5.1f%%%12zu\n",
+    fprintf (stderr, "%-32s%-48s " PRsa(5) PRsa(9) ":%5.1f%%"
+	     PRsa(9) PRsa(9) ":%5.1f%%%12" PRIu64 "\n",
 	     m_pool_name, location_string,
 	     SIZE_AMOUNT (m_instances),
 	     SIZE_AMOUNT (m_allocated),
@@ -72,7 +72,7 @@ struct pool_usage: public mem_usage
 	     SIZE_AMOUNT (m_peak),
 	     SIZE_AMOUNT (m_times),
 	     get_percent (m_times, total.m_times),
-	     m_element_size);
+	     (uint64_t)m_element_size);
 
     free (location_string);
   }
@@ -91,7 +91,7 @@ struct pool_usage: public mem_usage
   dump_footer ()
   {
     print_dash_line ();
-    fprintf (stderr, "%s%82zu%c%10zu%c\n", "Total",
+    fprintf (stderr, "%s" PRsa(82) PRsa(10) "\n", "Total",
 	     SIZE_AMOUNT (m_instances), SIZE_AMOUNT (m_allocated));
     print_dash_line ();
   }
diff --git a/gcc/bitmap.h b/gcc/bitmap.h
index 973ea846baf1..9a180daa7454 100644
--- a/gcc/bitmap.h
+++ b/gcc/bitmap.h
@@ -239,9 +239,9 @@ struct bitmap_usage: public mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-48s %9zu%c:%5.1f%%"
-	     "%9zu%c%9zu%c:%5.1f%%"
-	     "%11" PRIu64 "%c%11" PRIu64 "%c%10s\n",
+    fprintf (stderr, "%-48s " PRsa (9) ":%5.1f%%"
+	     PRsa (9) PRsa (9) ":%5.1f%%"
+	     PRsa (11) PRsa (11) "%10s\n",
 	     location_string, SIZE_AMOUNT (m_allocated),
 	     get_percent (m_allocated, total.m_allocated),
 	     SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times),
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 9fdba23ce4c2..c989fb01e669 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -884,8 +884,8 @@ struct ggc_usage: public mem_usage
   {
     size_t balance = get_balance ();
     fprintf (stderr,
-	     "%-48s %9zu%c:%5.1f%%%9zu%c:%5.1f%%"
-	     "%9zu%c:%5.1f%%%9zu%c:%5.1f%%%9zu%c\n",
+	     "%-48s " PRsa (9) ":%5.1f%%" PRsa (9) ":%5.1f%%"
+	     PRsa (9) ":%5.1f%%" PRsa (9) ":%5.1f%%" PRsa (9) "\n",
 	     prefix, SIZE_AMOUNT (m_collected),
 	     get_percent (m_collected, total.m_collected),
 	     SIZE_AMOUNT (m_freed), get_percent (m_freed, total.m_freed),
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 00c2864711f0..f04b22ca8cca 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -2288,14 +2288,15 @@ ggc_print_statistics (void)
 	  overhead += (sizeof (page_entry) - sizeof (long)
 		       + BITMAP_SIZE (OBJECTS_IN_PAGE (p) + 1));
 	}
-      fprintf (stderr, "%-8zu %10zu%c %10zu%c %10zu%c\n",
-	       OBJECT_SIZE (i),
+      fprintf (stderr, "%-8" PRIu64 " " PRsa (10) " " PRsa (10) " "
+	       PRsa (10) "\n",
+	       (uint64_t)OBJECT_SIZE (i),
 	       SIZE_AMOUNT (allocated),
 	       SIZE_AMOUNT (in_use),
 	       SIZE_AMOUNT (overhead));
       total_overhead += overhead;
     }
-  fprintf (stderr, "%-8s %10zu%c %10zu%c %10zu%c\n",
+  fprintf (stderr, "%-8s " PRsa (10) " " PRsa (10) " " PRsa (10) "\n",
 	   "Total",
 	   SIZE_AMOUNT (G.bytes_mapped),
 	   SIZE_AMOUNT (G.allocated),
@@ -2306,42 +2307,42 @@ ggc_print_statistics (void)
       fprintf (stderr, "\nTotal allocations and overheads during "
 	       "the compilation process\n");
 
-      fprintf (stderr, "Total Overhead:                          %9"
-	       HOST_LONG_LONG_FORMAT "d%c\n",
+      fprintf (stderr, "Total Overhead:                          "
+	       PRsa (9) "\n",
 	       SIZE_AMOUNT (G.stats.total_overhead));
-      fprintf (stderr, "Total Allocated:                         %9"
-	       HOST_LONG_LONG_FORMAT "d%c\n",
+      fprintf (stderr, "Total Allocated:                         "
+	       PRsa (9) "\n",
 	       SIZE_AMOUNT (G.stats.total_allocated));
 
-      fprintf (stderr, "Total Overhead  under  32B:              %9"
-	       HOST_LONG_LONG_FORMAT "d%c\n",
+      fprintf (stderr, "Total Overhead  under  32B:              "
+	       PRsa (9) "\n",
 	       SIZE_AMOUNT (G.stats.total_overhead_under32));
-      fprintf (stderr, "Total Allocated under  32B:              %9"
-	       HOST_LONG_LONG_FORMAT "d%c\n",
+      fprintf (stderr, "Total Allocated under  32B:              "
+	       PRsa (9) "\n",
 	       SIZE_AMOUNT (G.stats.total_allocated_under32));
-      fprintf (stderr, "Total Overhead  under  64B:              %9"
-	       HOST_LONG_LONG_FORMAT "d%c\n",
+      fprintf (stderr, "Total Overhead  under  64B:              "
+	       PRsa (9) "\n",
 	       SIZE_AMOUNT (G.stats.total_overhead_under64));
-      fprintf (stderr, "Total Allocated under  64B:              %9"
-	       HOST_LONG_LONG_FORMAT "d%c\n",
+      fprintf (stderr, "Total Allocated under  64B:              "
+	       PRsa (9) "\n",
 	       SIZE_AMOUNT (G.stats.total_allocated_under64));
-      fprintf (stderr, "Total Overhead  under 128B:              %9"
-	       HOST_LONG_LONG_FORMAT "d%c\n",
+      fprintf (stderr, "Total Overhead  under 128B:              "
+	       PRsa (9) "\n",
 	       SIZE_AMOUNT (G.stats.total_overhead_under128));
-      fprintf (stderr, "Total Allocated under 128B:              %9"
-	       HOST_LONG_LONG_FORMAT "d%c\n",
+      fprintf (stderr, "Total Allocated under 128B:              "
+	       PRsa (9) "\n",
 	       SIZE_AMOUNT (G.stats.total_allocated_under128));
 
       for (i = 0; i < NUM_ORDERS; i++)
 	if (G.stats.total_allocated_per_order[i])
 	  {
-	    fprintf (stderr, "Total Overhead  page size %9zu:     %9"
-		     HOST_LONG_LONG_FORMAT "d%c\n",
-		     OBJECT_SIZE (i),
+	    fprintf (stderr, "Total Overhead  page size %9" PRIu64 ":     "
+		     PRsa (9) "\n",
+		     (uint64_t)OBJECT_SIZE (i),
 		     SIZE_AMOUNT (G.stats.total_overhead_per_order[i]));
-	    fprintf (stderr, "Total Allocated page size %9zu:     %9"
-		     HOST_LONG_LONG_FORMAT "d%c\n",
-		     OBJECT_SIZE (i),
+	    fprintf (stderr, "Total Allocated page size %9" PRIu64 ":     "
+		     PRsa (9) "\n",
+		     (uint64_t)OBJECT_SIZE (i),
 		     SIZE_AMOUNT (G.stats.total_allocated_per_order[i]));
 	  }
   }
diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h
index 6ab92211cf47..219959faa992 100644
--- a/gcc/mem-stats.h
+++ b/gcc/mem-stats.h
@@ -205,8 +205,8 @@ struct mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-48s %9zu%c:%5.1f%%"
-	     "%9zu%c%9zu%c:%5.1f%%%10s\n",
+    fprintf (stderr, "%-48s " PRsa (9) ":%5.1f%%"
+	     PRsa (9) PRsa (9) ":%5.1f%%%10s\n",
 	     location_string, SIZE_AMOUNT (m_allocated),
 	     get_percent (m_allocated, total.m_allocated),
 	     SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times),
@@ -220,7 +220,7 @@ struct mem_usage
   dump_footer () const
   {
     print_dash_line ();
-    fprintf (stderr, "%s%53zu%c%26zu%c\n", "Total",
+    fprintf (stderr, "%s" PRsa (53) PRsa (26) "\n", "Total",
 	     SIZE_AMOUNT (m_allocated), SIZE_AMOUNT (m_times));
     print_dash_line ();
   }
diff --git a/gcc/rtl.c b/gcc/rtl.c
index bf897bf75b4e..2ab349981d9b 100644
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -821,7 +821,7 @@ dump_rtx_statistics (void)
       unsigned j = indices[i];
       if (rtx_alloc_counts[j])
 	{
-	  fprintf (stderr, "%-24s %6zu%c %9zu%c\n",
+	  fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n",
 		   GET_RTX_NAME (j),
 		   SIZE_AMOUNT (rtx_alloc_counts[j]),
 		   SIZE_AMOUNT (rtx_alloc_sizes[j]));
@@ -832,14 +832,14 @@ dump_rtx_statistics (void)
 
   if (rtvec_alloc_counts)
     {
-      fprintf (stderr, "%-24s %6zu%c %9zu%c\n", "rtvec",
+      fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n", "rtvec",
 	       SIZE_AMOUNT (rtvec_alloc_counts),
 	       SIZE_AMOUNT (rtvec_alloc_sizes));
       total_counts += rtvec_alloc_counts;
       total_sizes += rtvec_alloc_sizes;
     }
   fprintf (stderr, "-----------------------------------------------\n");
-  fprintf (stderr, "%-24s %6d%c %9d%c\n",
+  fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n",
 	   "Total", SIZE_AMOUNT (total_counts),
 	   SIZE_AMOUNT (total_sizes));
   fprintf (stderr, "-----------------------------------------------\n");
diff --git a/gcc/system.h b/gcc/system.h
index ba328213a693..d23300f5e5db 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1231,6 +1231,10 @@ void gcc_stablesort (void *, size_t, size_t,
 /* Display an integer amount as multiple of 1K or 1M (in base 2).
    Display the correct unit (either k, M, or ' ') after the amount, as
    well.  */
-#define SIZE_AMOUNT(size) SIZE_SCALE (size), SIZE_LABEL (size)
+#define SIZE_AMOUNT(size) (uint64_t)SIZE_SCALE (size), SIZE_LABEL (size)
+
+/* Format string particle for printing a SIZE_AMOUNT with N being the width
+   of the number.  */
+#define PRsa(n) "%" #n PRIu64 "%c"
 
 #endif /* ! GCC_SYSTEM_H */
diff --git a/gcc/vec.c b/gcc/vec.c
index bd49d0358c5c..c08ef0445af6 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -83,13 +83,13 @@ struct vec_usage: public mem_usage
     s[48] = '\0';
 
     fprintf (stderr,
-	     "%-48s %10zu%10zu%c:%4.1f%%%9zu%c%10zu"
-	     ":%4.1f%%%10zu%c%10zu%c\n",
+	     "%-48s %10" PRIu64 PRsa (10) ":%4.1f%%" PRsa (9) "%10" PRIu64
+	     ":%4.1f%%" PRsa (10) PRsa (10) "\n",
 	     s,
-	     m_element_size,
+	     (uint64_t)m_element_size,
 	     SIZE_AMOUNT (m_allocated),
 	     m_allocated * 100.0 / total.m_allocated,
-	     SIZE_AMOUNT (m_peak), m_times,
+	     SIZE_AMOUNT (m_peak), (uint64_t)m_times,
 	     m_times * 100.0 / total.m_times,
 	     SIZE_AMOUNT (m_items), SIZE_AMOUNT (m_items_peak));
   }
@@ -99,7 +99,7 @@ struct vec_usage: public mem_usage
   dump_footer ()
   {
     print_dash_line ();
-    fprintf (stderr, "%s%64zu%c%25zu%c%16zu%c\n",
+    fprintf (stderr, "%s" PRsa (64) PRsa (25) PRsa (16) "\n",
 	     "Total", SIZE_AMOUNT (m_allocated),
 	     SIZE_AMOUNT (m_times), SIZE_AMOUNT (m_items));
     print_dash_line ();
Richard Biener Nov. 15, 2018, 3:08 p.m. | #6
On Thu, Nov 15, 2018 at 2:31 PM Michael Matz <matz@suse.de> wrote:
>

> Hi,

>

> On Thu, 15 Nov 2018, Richard Biener wrote:

>

> > > Okay, probably.  Then consider the same patch with sprinkling casts to

> > > long for all these arguments (the actual numbers will fit that type in

> > > reality).  I could of course also use PRIu64 but that makes my eyes

> > > bleed.

> >

> > Hmm.  Can you use PRIu64 please and cast to uint64_t?  OK with that

> > change.

>

> Instead I'd like to check in this.  It adds a new macro expanding to

>   "%" #n PRIu64 "%c"

> (with n being the width) corresponding to one SIZE_AMOUNT macro "argument"

> (which are actually two arguments), and hides the cast in the latter macro

> itself.  At least the number of format string args and actual args

> corresponds again then and my eyes bleed a little less.  Still okay?


Works for me.

Richard.

>

> Ciao,

> Michael.

>

>         * system.h (PRsa): New macro.

>         (SIZE_AMOUNT): Cast number to uint64_t.

>         * alloc-pool.h (pool_usage::dump): Don't use %zu but PRsa.

>         (pool_usage::dump_footer): Likewise and also use PRIu64.

>         * bitmap.h (bitmap_usage::dump): Likewise.

>         * ggc-common.c (ggc_usage::dump): Likewise.

>         * ggc-page.c (ggc_print_statistics): Likewise.

>         * mem-stats.h (mem_usage::dump): Likewise.

>         (mem_usage::dump_footer): Likewise.

>         * rtl.c (dump_rtx_statistics): Likewise.

>         * vec.c (vec_usage::dump): Likewise.

>         (vec_usage::dump_footer): Likewise.

>

> diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h

> index d17a05ca4fb1..81cb69e227ab 100644

> --- a/gcc/alloc-pool.h

> +++ b/gcc/alloc-pool.h

> @@ -63,8 +63,8 @@ struct pool_usage: public mem_usage

>    {

>      char *location_string = loc->to_string ();

>

> -    fprintf (stderr, "%-32s%-48s %5zu%c%9zu%c:%5.1f%%%9zu"

> -            "%c%9zu%c:%5.1f%%%12zu\n",

> +    fprintf (stderr, "%-32s%-48s " PRsa(5) PRsa(9) ":%5.1f%%"

> +            PRsa(9) PRsa(9) ":%5.1f%%%12" PRIu64 "\n",

>              m_pool_name, location_string,

>              SIZE_AMOUNT (m_instances),

>              SIZE_AMOUNT (m_allocated),

> @@ -72,7 +72,7 @@ struct pool_usage: public mem_usage

>              SIZE_AMOUNT (m_peak),

>              SIZE_AMOUNT (m_times),

>              get_percent (m_times, total.m_times),

> -            m_element_size);

> +            (uint64_t)m_element_size);

>

>      free (location_string);

>    }

> @@ -91,7 +91,7 @@ struct pool_usage: public mem_usage

>    dump_footer ()

>    {

>      print_dash_line ();

> -    fprintf (stderr, "%s%82zu%c%10zu%c\n", "Total",

> +    fprintf (stderr, "%s" PRsa(82) PRsa(10) "\n", "Total",

>              SIZE_AMOUNT (m_instances), SIZE_AMOUNT (m_allocated));

>      print_dash_line ();

>    }

> diff --git a/gcc/bitmap.h b/gcc/bitmap.h

> index 973ea846baf1..9a180daa7454 100644

> --- a/gcc/bitmap.h

> +++ b/gcc/bitmap.h

> @@ -239,9 +239,9 @@ struct bitmap_usage: public mem_usage

>    {

>      char *location_string = loc->to_string ();

>

> -    fprintf (stderr, "%-48s %9zu%c:%5.1f%%"

> -            "%9zu%c%9zu%c:%5.1f%%"

> -            "%11" PRIu64 "%c%11" PRIu64 "%c%10s\n",

> +    fprintf (stderr, "%-48s " PRsa (9) ":%5.1f%%"

> +            PRsa (9) PRsa (9) ":%5.1f%%"

> +            PRsa (11) PRsa (11) "%10s\n",

>              location_string, SIZE_AMOUNT (m_allocated),

>              get_percent (m_allocated, total.m_allocated),

>              SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times),

> diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c

> index 9fdba23ce4c2..c989fb01e669 100644

> --- a/gcc/ggc-common.c

> +++ b/gcc/ggc-common.c

> @@ -884,8 +884,8 @@ struct ggc_usage: public mem_usage

>    {

>      size_t balance = get_balance ();

>      fprintf (stderr,

> -            "%-48s %9zu%c:%5.1f%%%9zu%c:%5.1f%%"

> -            "%9zu%c:%5.1f%%%9zu%c:%5.1f%%%9zu%c\n",

> +            "%-48s " PRsa (9) ":%5.1f%%" PRsa (9) ":%5.1f%%"

> +            PRsa (9) ":%5.1f%%" PRsa (9) ":%5.1f%%" PRsa (9) "\n",

>              prefix, SIZE_AMOUNT (m_collected),

>              get_percent (m_collected, total.m_collected),

>              SIZE_AMOUNT (m_freed), get_percent (m_freed, total.m_freed),

> diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c

> index 00c2864711f0..f04b22ca8cca 100644

> --- a/gcc/ggc-page.c

> +++ b/gcc/ggc-page.c

> @@ -2288,14 +2288,15 @@ ggc_print_statistics (void)

>           overhead += (sizeof (page_entry) - sizeof (long)

>                        + BITMAP_SIZE (OBJECTS_IN_PAGE (p) + 1));

>         }

> -      fprintf (stderr, "%-8zu %10zu%c %10zu%c %10zu%c\n",

> -              OBJECT_SIZE (i),

> +      fprintf (stderr, "%-8" PRIu64 " " PRsa (10) " " PRsa (10) " "

> +              PRsa (10) "\n",

> +              (uint64_t)OBJECT_SIZE (i),

>                SIZE_AMOUNT (allocated),

>                SIZE_AMOUNT (in_use),

>                SIZE_AMOUNT (overhead));

>        total_overhead += overhead;

>      }

> -  fprintf (stderr, "%-8s %10zu%c %10zu%c %10zu%c\n",

> +  fprintf (stderr, "%-8s " PRsa (10) " " PRsa (10) " " PRsa (10) "\n",

>            "Total",

>            SIZE_AMOUNT (G.bytes_mapped),

>            SIZE_AMOUNT (G.allocated),

> @@ -2306,42 +2307,42 @@ ggc_print_statistics (void)

>        fprintf (stderr, "\nTotal allocations and overheads during "

>                "the compilation process\n");

>

> -      fprintf (stderr, "Total Overhead:                          %9"

> -              HOST_LONG_LONG_FORMAT "d%c\n",

> +      fprintf (stderr, "Total Overhead:                          "

> +              PRsa (9) "\n",

>                SIZE_AMOUNT (G.stats.total_overhead));

> -      fprintf (stderr, "Total Allocated:                         %9"

> -              HOST_LONG_LONG_FORMAT "d%c\n",

> +      fprintf (stderr, "Total Allocated:                         "

> +              PRsa (9) "\n",

>                SIZE_AMOUNT (G.stats.total_allocated));

>

> -      fprintf (stderr, "Total Overhead  under  32B:              %9"

> -              HOST_LONG_LONG_FORMAT "d%c\n",

> +      fprintf (stderr, "Total Overhead  under  32B:              "

> +              PRsa (9) "\n",

>                SIZE_AMOUNT (G.stats.total_overhead_under32));

> -      fprintf (stderr, "Total Allocated under  32B:              %9"

> -              HOST_LONG_LONG_FORMAT "d%c\n",

> +      fprintf (stderr, "Total Allocated under  32B:              "

> +              PRsa (9) "\n",

>                SIZE_AMOUNT (G.stats.total_allocated_under32));

> -      fprintf (stderr, "Total Overhead  under  64B:              %9"

> -              HOST_LONG_LONG_FORMAT "d%c\n",

> +      fprintf (stderr, "Total Overhead  under  64B:              "

> +              PRsa (9) "\n",

>                SIZE_AMOUNT (G.stats.total_overhead_under64));

> -      fprintf (stderr, "Total Allocated under  64B:              %9"

> -              HOST_LONG_LONG_FORMAT "d%c\n",

> +      fprintf (stderr, "Total Allocated under  64B:              "

> +              PRsa (9) "\n",

>                SIZE_AMOUNT (G.stats.total_allocated_under64));

> -      fprintf (stderr, "Total Overhead  under 128B:              %9"

> -              HOST_LONG_LONG_FORMAT "d%c\n",

> +      fprintf (stderr, "Total Overhead  under 128B:              "

> +              PRsa (9) "\n",

>                SIZE_AMOUNT (G.stats.total_overhead_under128));

> -      fprintf (stderr, "Total Allocated under 128B:              %9"

> -              HOST_LONG_LONG_FORMAT "d%c\n",

> +      fprintf (stderr, "Total Allocated under 128B:              "

> +              PRsa (9) "\n",

>                SIZE_AMOUNT (G.stats.total_allocated_under128));

>

>        for (i = 0; i < NUM_ORDERS; i++)

>         if (G.stats.total_allocated_per_order[i])

>           {

> -           fprintf (stderr, "Total Overhead  page size %9zu:     %9"

> -                    HOST_LONG_LONG_FORMAT "d%c\n",

> -                    OBJECT_SIZE (i),

> +           fprintf (stderr, "Total Overhead  page size %9" PRIu64 ":     "

> +                    PRsa (9) "\n",

> +                    (uint64_t)OBJECT_SIZE (i),

>                      SIZE_AMOUNT (G.stats.total_overhead_per_order[i]));

> -           fprintf (stderr, "Total Allocated page size %9zu:     %9"

> -                    HOST_LONG_LONG_FORMAT "d%c\n",

> -                    OBJECT_SIZE (i),

> +           fprintf (stderr, "Total Allocated page size %9" PRIu64 ":     "

> +                    PRsa (9) "\n",

> +                    (uint64_t)OBJECT_SIZE (i),

>                      SIZE_AMOUNT (G.stats.total_allocated_per_order[i]));

>           }

>    }

> diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h

> index 6ab92211cf47..219959faa992 100644

> --- a/gcc/mem-stats.h

> +++ b/gcc/mem-stats.h

> @@ -205,8 +205,8 @@ struct mem_usage

>    {

>      char *location_string = loc->to_string ();

>

> -    fprintf (stderr, "%-48s %9zu%c:%5.1f%%"

> -            "%9zu%c%9zu%c:%5.1f%%%10s\n",

> +    fprintf (stderr, "%-48s " PRsa (9) ":%5.1f%%"

> +            PRsa (9) PRsa (9) ":%5.1f%%%10s\n",

>              location_string, SIZE_AMOUNT (m_allocated),

>              get_percent (m_allocated, total.m_allocated),

>              SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times),

> @@ -220,7 +220,7 @@ struct mem_usage

>    dump_footer () const

>    {

>      print_dash_line ();

> -    fprintf (stderr, "%s%53zu%c%26zu%c\n", "Total",

> +    fprintf (stderr, "%s" PRsa (53) PRsa (26) "\n", "Total",

>              SIZE_AMOUNT (m_allocated), SIZE_AMOUNT (m_times));

>      print_dash_line ();

>    }

> diff --git a/gcc/rtl.c b/gcc/rtl.c

> index bf897bf75b4e..2ab349981d9b 100644

> --- a/gcc/rtl.c

> +++ b/gcc/rtl.c

> @@ -821,7 +821,7 @@ dump_rtx_statistics (void)

>        unsigned j = indices[i];

>        if (rtx_alloc_counts[j])

>         {

> -         fprintf (stderr, "%-24s %6zu%c %9zu%c\n",

> +         fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n",

>                    GET_RTX_NAME (j),

>                    SIZE_AMOUNT (rtx_alloc_counts[j]),

>                    SIZE_AMOUNT (rtx_alloc_sizes[j]));

> @@ -832,14 +832,14 @@ dump_rtx_statistics (void)

>

>    if (rtvec_alloc_counts)

>      {

> -      fprintf (stderr, "%-24s %6zu%c %9zu%c\n", "rtvec",

> +      fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n", "rtvec",

>                SIZE_AMOUNT (rtvec_alloc_counts),

>                SIZE_AMOUNT (rtvec_alloc_sizes));

>        total_counts += rtvec_alloc_counts;

>        total_sizes += rtvec_alloc_sizes;

>      }

>    fprintf (stderr, "-----------------------------------------------\n");

> -  fprintf (stderr, "%-24s %6d%c %9d%c\n",

> +  fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n",

>            "Total", SIZE_AMOUNT (total_counts),

>            SIZE_AMOUNT (total_sizes));

>    fprintf (stderr, "-----------------------------------------------\n");

> diff --git a/gcc/system.h b/gcc/system.h

> index ba328213a693..d23300f5e5db 100644

> --- a/gcc/system.h

> +++ b/gcc/system.h

> @@ -1231,6 +1231,10 @@ void gcc_stablesort (void *, size_t, size_t,

>  /* Display an integer amount as multiple of 1K or 1M (in base 2).

>     Display the correct unit (either k, M, or ' ') after the amount, as

>     well.  */

> -#define SIZE_AMOUNT(size) SIZE_SCALE (size), SIZE_LABEL (size)

> +#define SIZE_AMOUNT(size) (uint64_t)SIZE_SCALE (size), SIZE_LABEL (size)

> +

> +/* Format string particle for printing a SIZE_AMOUNT with N being the width

> +   of the number.  */

> +#define PRsa(n) "%" #n PRIu64 "%c"

>

>  #endif /* ! GCC_SYSTEM_H */

> diff --git a/gcc/vec.c b/gcc/vec.c

> index bd49d0358c5c..c08ef0445af6 100644

> --- a/gcc/vec.c

> +++ b/gcc/vec.c

> @@ -83,13 +83,13 @@ struct vec_usage: public mem_usage

>      s[48] = '\0';

>

>      fprintf (stderr,

> -            "%-48s %10zu%10zu%c:%4.1f%%%9zu%c%10zu"

> -            ":%4.1f%%%10zu%c%10zu%c\n",

> +            "%-48s %10" PRIu64 PRsa (10) ":%4.1f%%" PRsa (9) "%10" PRIu64

> +            ":%4.1f%%" PRsa (10) PRsa (10) "\n",

>              s,

> -            m_element_size,

> +            (uint64_t)m_element_size,

>              SIZE_AMOUNT (m_allocated),

>              m_allocated * 100.0 / total.m_allocated,

> -            SIZE_AMOUNT (m_peak), m_times,

> +            SIZE_AMOUNT (m_peak), (uint64_t)m_times,

>              m_times * 100.0 / total.m_times,

>              SIZE_AMOUNT (m_items), SIZE_AMOUNT (m_items_peak));

>    }

> @@ -99,7 +99,7 @@ struct vec_usage: public mem_usage

>    dump_footer ()

>    {

>      print_dash_line ();

> -    fprintf (stderr, "%s%64zu%c%25zu%c%16zu%c\n",

> +    fprintf (stderr, "%s" PRsa (64) PRsa (25) PRsa (16) "\n",

>              "Total", SIZE_AMOUNT (m_allocated),

>              SIZE_AMOUNT (m_times), SIZE_AMOUNT (m_items));

>      print_dash_line ();

Patch

diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index d17a05ca4fb1..8a6747d89cc6 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -63,8 +63,8 @@  struct pool_usage: public mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-32s%-48s %5zu%c%9zu%c:%5.1f%%%9zu"
-	     "%c%9zu%c:%5.1f%%%12zu\n",
+    fprintf (stderr, "%-32s%-48s %5lu%c%9lu%c:%5.1f%%%9lu"
+	     "%c%9lu%c:%5.1f%%%12lu\n",
 	     m_pool_name, location_string,
 	     SIZE_AMOUNT (m_instances),
 	     SIZE_AMOUNT (m_allocated),
@@ -91,7 +91,7 @@  struct pool_usage: public mem_usage
   dump_footer ()
   {
     print_dash_line ();
-    fprintf (stderr, "%s%82zu%c%10zu%c\n", "Total",
+    fprintf (stderr, "%s%82lu%c%10lu%c\n", "Total",
 	     SIZE_AMOUNT (m_instances), SIZE_AMOUNT (m_allocated));
     print_dash_line ();
   }
diff --git a/gcc/bitmap.h b/gcc/bitmap.h
index 973ea846baf1..7c547aba9a5b 100644
--- a/gcc/bitmap.h
+++ b/gcc/bitmap.h
@@ -239,8 +239,8 @@  struct bitmap_usage: public mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-48s %9zu%c:%5.1f%%"
-	     "%9zu%c%9zu%c:%5.1f%%"
+    fprintf (stderr, "%-48s %9lu%c:%5.1f%%"
+	     "%9lu%c%9lu%c:%5.1f%%"
 	     "%11" PRIu64 "%c%11" PRIu64 "%c%10s\n",
 	     location_string, SIZE_AMOUNT (m_allocated),
 	     get_percent (m_allocated, total.m_allocated),
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 9fdba23ce4c2..0fe06ccd653d 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -884,12 +884,13 @@  struct ggc_usage: public mem_usage
   {
     size_t balance = get_balance ();
     fprintf (stderr,
-	     "%-48s %9zu%c:%5.1f%%%9zu%c:%5.1f%%"
-	     "%9zu%c:%5.1f%%%9zu%c:%5.1f%%%9zu%c\n",
+	     "%-48s %9lu%c:%5.1f%%%9lu%c:%5.1f%%"
+	     "%9lu%c:%5.1f%%%9lu%c:%5.1f%%%9lu%c\n",
 	     prefix, SIZE_AMOUNT (m_collected),
 	     get_percent (m_collected, total.m_collected),
 	     SIZE_AMOUNT (m_freed), get_percent (m_freed, total.m_freed),
-	     SIZE_AMOUNT (balance), get_percent (balance, total.get_balance ()),
+	     SIZE_AMOUNT (balance),
+	     get_percent (balance, total.get_balance ()),
 	     SIZE_AMOUNT (m_overhead),
 	     get_percent (m_overhead, total.m_overhead),
 	     SIZE_AMOUNT (m_times));
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 00c2864711f0..6ead4a144390 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -2288,14 +2288,14 @@  ggc_print_statistics (void)
 	  overhead += (sizeof (page_entry) - sizeof (long)
 		       + BITMAP_SIZE (OBJECTS_IN_PAGE (p) + 1));
 	}
-      fprintf (stderr, "%-8zu %10zu%c %10zu%c %10zu%c\n",
+      fprintf (stderr, "%-8lu %10lu%c %10lu%c %10lu%c\n",
 	       OBJECT_SIZE (i),
 	       SIZE_AMOUNT (allocated),
 	       SIZE_AMOUNT (in_use),
 	       SIZE_AMOUNT (overhead));
       total_overhead += overhead;
     }
-  fprintf (stderr, "%-8s %10zu%c %10zu%c %10zu%c\n",
+  fprintf (stderr, "%-8s %10lu%c %10lu%c %10lu%c\n",
 	   "Total",
 	   SIZE_AMOUNT (G.bytes_mapped),
 	   SIZE_AMOUNT (G.allocated),
@@ -2335,11 +2335,11 @@  ggc_print_statistics (void)
       for (i = 0; i < NUM_ORDERS; i++)
 	if (G.stats.total_allocated_per_order[i])
 	  {
-	    fprintf (stderr, "Total Overhead  page size %9zu:     %9"
+	    fprintf (stderr, "Total Overhead  page size %9lu:     %9"
 		     HOST_LONG_LONG_FORMAT "d%c\n",
 		     OBJECT_SIZE (i),
 		     SIZE_AMOUNT (G.stats.total_overhead_per_order[i]));
-	    fprintf (stderr, "Total Allocated page size %9zu:     %9"
+	    fprintf (stderr, "Total Allocated page size %9lu:     %9"
 		     HOST_LONG_LONG_FORMAT "d%c\n",
 		     OBJECT_SIZE (i),
 		     SIZE_AMOUNT (G.stats.total_allocated_per_order[i]));
diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h
index 6ab92211cf47..a2da009f100e 100644
--- a/gcc/mem-stats.h
+++ b/gcc/mem-stats.h
@@ -205,8 +205,8 @@  struct mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-48s %9zu%c:%5.1f%%"
-	     "%9zu%c%9zu%c:%5.1f%%%10s\n",
+    fprintf (stderr, "%-48s %9lu%c:%5.1f%%"
+	     "%9lu%c%9lu%c:%5.1f%%%10s\n",
 	     location_string, SIZE_AMOUNT (m_allocated),
 	     get_percent (m_allocated, total.m_allocated),
 	     SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times),
@@ -220,7 +220,7 @@  struct mem_usage
   dump_footer () const
   {
     print_dash_line ();
-    fprintf (stderr, "%s%53zu%c%26zu%c\n", "Total",
+    fprintf (stderr, "%s%53lu%c%26lu%c\n", "Total",
 	     SIZE_AMOUNT (m_allocated), SIZE_AMOUNT (m_times));
     print_dash_line ();
   }
diff --git a/gcc/rtl.c b/gcc/rtl.c
index bf897bf75b4e..c253810832e3 100644
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -821,7 +821,7 @@  dump_rtx_statistics (void)
       unsigned j = indices[i];
       if (rtx_alloc_counts[j])
 	{
-	  fprintf (stderr, "%-24s %6zu%c %9zu%c\n",
+	  fprintf (stderr, "%-24s %6lu%c %9lu%c\n",
 		   GET_RTX_NAME (j),
 		   SIZE_AMOUNT (rtx_alloc_counts[j]),
 		   SIZE_AMOUNT (rtx_alloc_sizes[j]));
@@ -832,7 +832,7 @@  dump_rtx_statistics (void)
 
   if (rtvec_alloc_counts)
     {
-      fprintf (stderr, "%-24s %6zu%c %9zu%c\n", "rtvec",
+      fprintf (stderr, "%-24s %6lu%c %9lu%c\n", "rtvec",
 	       SIZE_AMOUNT (rtvec_alloc_counts),
 	       SIZE_AMOUNT (rtvec_alloc_sizes));
       total_counts += rtvec_alloc_counts;
diff --git a/gcc/vec.c b/gcc/vec.c
index bd49d0358c5c..2a76ae03337e 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -83,8 +83,8 @@  struct vec_usage: public mem_usage
     s[48] = '\0';
 
     fprintf (stderr,
-	     "%-48s %10zu%10zu%c:%4.1f%%%9zu%c%10zu"
-	     ":%4.1f%%%10zu%c%10zu%c\n",
+	     "%-48s %10lu%10lu%c:%4.1f%%%9lu%c%10lu"
+	     ":%4.1f%%%10lu%c%10lu%c\n",
 	     s,
 	     m_element_size,
 	     SIZE_AMOUNT (m_allocated),
@@ -99,7 +99,7 @@  struct vec_usage: public mem_usage
   dump_footer ()
   {
     print_dash_line ();
-    fprintf (stderr, "%s%64zu%c%25zu%c%16zu%c\n",
+    fprintf (stderr, "%s%64lu%c%25lu%c%16lu%c\n",
 	     "Total", SIZE_AMOUNT (m_allocated),
 	     SIZE_AMOUNT (m_times), SIZE_AMOUNT (m_items));
     print_dash_line ();