Hi,

this fixes a few -Wshadow=local warnings in hash-table.h.

Since values of type size_t are assigned here to int variables
an overflow may happen resulting in memory leaks or malfunction.


Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.

2019-10-03  Bernd Edlinger  <bernd.edlin...@hotmail.de>

	* hash-table.h (hash_table::empty_slow): Don't assign
	size_t values to int variables.

Index: gcc/hash-table.h
===================================================================
--- gcc/hash-table.h	(revision 276484)
+++ gcc/hash-table.h	(working copy)
@@ -842,9 +842,8 @@ hash_table<Descriptor, Lazy, Allocator>::empty_slo
   size_t size = m_size;
   size_t nsize = size;
   value_type *entries = m_entries;
-  int i;
 
-  for (i = size - 1; i >= 0; i--)
+  for (size_t i = size - 1; i < size; i--)
     if (!is_empty (entries[i]) && !is_deleted (entries[i]))
       Descriptor::remove (entries[i]);
 
@@ -856,9 +855,10 @@ hash_table<Descriptor, Lazy, Allocator>::empty_slo
 
   if (nsize != size)
     {
-      int nindex = hash_table_higher_prime_index (nsize);
-      int nsize = prime_tab[nindex].prime;
+      unsigned int nindex = hash_table_higher_prime_index (nsize);
 
+      nsize = prime_tab[nindex].prime;
+
       if (!m_ggc)
 	Allocator <value_type> ::data_free (m_entries);
       else

Reply via email to