This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, v3] Do not shift by larger than size in

The patch below fixes the following build failure on
x86_64-unknown-linux-gnu when --enable-maintainer-mode is used
(which turns on -Werror here):

libtool: compile:  /tmp/build/./gcc/xgcc -shared-libgcc -B/tmp/build/./gcc -nostdinc++ -L/tmp/build/x86_64-unknown-linux-gnu/32/libstdc++-v3/src -L/tmp/build/x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs -B/opt/gcc-4.6/x86_64-unknown-linux-gnu/bin/ -B/opt/gcc-4.6/x86_64-unknown-linux-gnu/lib/ -isystem /opt/gcc-4.6/x86_64-unknown-linux-gnu/include -isystem /opt/gcc-4.6/x86_64-unknown-linux-gnu/sys-include -m32 -I/tmp/build/x86_64-unknown-linux-gnu/32/libstdc++-v3/include/x86_64-unknown-linux-gnu -I/tmp/build/x86_64-unknown-linux-gnu/32/libstdc++-v3/include -I/tmp/gcc/libstdc++-v3/libsupc++ -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Werror -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -g -O2 -D_GNU_SOURCE -m32 -std=gnu++0x -c ../../../../../gcc/libstdc++-v3/src/  -fPIC -DPIC -o .libs/hash_bytes.o
../../../../../gcc/libstdc++-v3/src/ In function âstd::size_t {anonymous}::shift_mix(std::size_t)â:
../../../../../gcc/libstdc++-v3/src/ error: right shift count >= width of type [-Werror]
cc1plus: all warnings being treated as errors
make[8]: *** [hash_bytes.lo] Error 1
make[8]: Leaving directory `/tmp/build/x86_64-unknown-linux-gnu/32/libstdc++-v3/src'

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.

If not, OK for trunk?


Do not shift by larger than size.

2010-09-19  Ralf Wildenhues  <>

	* src/ (shift_mix): Do not shift by larger than size.

diff --git a/libstdc++-v3/src/ b/libstdc++-v3/src/
index 5dfa1ee..9db25a2 100644
--- a/libstdc++-v3/src/
+++ b/libstdc++-v3/src/
@@ -59,7 +59,7 @@ namespace
   inline std::size_t
   shift_mix(std::size_t v)
-  { return v ^ (v >> 47);}
+  { return v ^ ((v >> 31) >> 16);}
 namespace std

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]