Patchwork [v3] Do not shift by larger than size in hash_bytes.cc

login
register
mail settings
Submitter Paolo Carlini
Date Sept. 19, 2010, 8:51 a.m.
Message ID <4C95CEF9.2080703@oracle.com>
Download mbox | patch
Permalink /patch/65152/
State New
Headers show

Comments

Paolo Carlini - Sept. 19, 2010, 8:51 a.m.
HI Ralf,

and thanks for noticing the warning,
> Regtested, no regressions.  It seems to me however that the warning
> hints that the code needs more adjustments for 32 bit size_t, or that
> load_bytes and shift_mix can be enclosed in '#if __SIZEOF_SIZE_T__ == 8'
> because they seem unused in the 32 bit case.
yes, I'm going to simply commit the below.

Thanks again,
Paolo.

////////////////
2010-09-19  Paolo Carlini  <paolo.carlini@oracle.com>

	* src/hash_bytes.cc: Compile load_bytes and shift_mix only when
	__SIZEOF_SIZE_T__ == 8.

Patch

Index: src/hash_bytes.cc
===================================================================
--- src/hash_bytes.cc	(revision 164387)
+++ src/hash_bytes.cc	(working copy)
@@ -45,6 +45,7 @@ 
     return result;
   }
 
+#if __SIZEOF_SIZE_T__ == 8
   // Loads n bytes, where 1 <= n < 8.
   inline std::size_t
   load_bytes(const char* p, int n)
@@ -60,6 +61,7 @@ 
   inline std::size_t
   shift_mix(std::size_t v)
   { return v ^ (v >> 47);}
+#endif
 }
 
 namespace std