Patch to change hashtab.h hashval_t to size_t

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Wed Oct 9 10:38:00 GMT 2002


When bootstrapping on sparcv9-sun-solaris2.7 (but I suspect you'll see
it on any LP64 platform) I get these warnings:

 > cp/decl.c:5520: warning: cast from pointer to integer of different size
 > cp/decl.c:5521: warning: cast from pointer to integer of different size
 > java/class.c:2279: warning: cast from pointer to integer of different size
 > java/class.c:2298: warning: cast from pointer to integer of different size
 > java/class.c:2313: warning: cast from pointer to integer of different size
 > function.c:3284: warning: cast from pointer to integer of different size

These warnings arise because in each case, pointer(s) used in
computing hash values are cast to a hashval_t.  Currently hashval_t is
an unsigned int, and on LP64 platforms we're stripping bits off.

Using size_t instead seems to be the generally accepted way within our
sources to ensure casting between pointers and integers aren't
truncated.

I tested this on sparc-solaris2.7.  I also 3-staged it on
sparcv9-solaris2.7 and the warnings went away.

Ok to install?

		Thanks,
		--Kaveh


2002-10-09  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* hashtab.h (hashval_t): Change type to size_t.

diff -rup orig/egcc-CVS20021008/include/hashtab.h egcc-CVS20021008/include/hashtab.h
--- orig/egcc-CVS20021008/include/hashtab.h	2002-10-09 10:50:35.772027048 -0400
+++ egcc-CVS20021008/include/hashtab.h	2002-10-09 10:27:30.133492295 -0400
@@ -43,7 +43,7 @@ extern "C" {
 #endif
 
 /* The type for a hash code.  */
-typedef unsigned int hashval_t;
+typedef size_t hashval_t;
 
 /* Callback function pointer types.  */
 



More information about the Gcc-patches mailing list