From patchwork Sun Sep 19 08:16:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ralf Wildenhues X-Patchwork-Id: 65149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 3370AB70D2 for ; Sun, 19 Sep 2010 18:16:20 +1000 (EST) Received: (qmail 3385 invoked by alias); 19 Sep 2010 08:16:17 -0000 Received: (qmail 3374 invoked by uid 22791); 19 Sep 2010 08:16:16 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mail.gmx.net) (213.165.64.22) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Sun, 19 Sep 2010 08:16:10 +0000 Received: (qmail invoked by alias); 19 Sep 2010 08:16:08 -0000 Received: from xdsl-89-0-68-71.netcologne.de (EHLO localhost.localdomain) [89.0.68.71] by mail.gmx.net (mp070) with SMTP; 19 Sep 2010 10:16:08 +0200 Received: from ralf by localhost.localdomain with local (Exim 4.69) (envelope-from ) id 1OxF4B-0001UA-IZ; Sun, 19 Sep 2010 10:16:07 +0200 Date: Sun, 19 Sep 2010 10:16:07 +0200 From: Ralf Wildenhues To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Cc: Matt Austern , paolo.carlini@oracle.com Subject: [PATCH, v3] Do not shift by larger than size in hash_bytes.cc Message-ID: <20100919081607.GD5435@gmx.de> Mail-Followup-To: Ralf Wildenhues , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, Matt Austern , paolo.carlini@oracle.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2010-08-04) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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/hash_bytes.cc -fPIC -DPIC -o .libs/hash_bytes.o ../../../../../gcc/libstdc++-v3/src/hash_bytes.cc: In function ‘std::size_t {anonymous}::shift_mix(std::size_t)’: ../../../../../gcc/libstdc++-v3/src/hash_bytes.cc:62:22: 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? Thanks, Ralf Do not shift by larger than size. libstdc++-v3/ChangeLog: 2010-09-19 Ralf Wildenhues * src/hash_bytes.cc (shift_mix): Do not shift by larger than size. diff --git a/libstdc++-v3/src/hash_bytes.cc b/libstdc++-v3/src/hash_bytes.cc index 5dfa1ee..9db25a2 100644 --- a/libstdc++-v3/src/hash_bytes.cc +++ b/libstdc++-v3/src/hash_bytes.cc @@ -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