From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26741 invoked by alias); 1 Nov 2002 04:46:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 26702 invoked by uid 71); 1 Nov 2002 04:46:01 -0000 Resent-Date: 1 Nov 2002 04:46:01 -0000 Resent-Message-ID: <20021101044601.26701.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, carlo@alinoe.com Received: (qmail 27744 invoked by uid 61); 1 Nov 2002 04:38:51 -0000 Message-Id: <20021101043851.27742.qmail@sources.redhat.com> Date: Thu, 31 Oct 2002 20:46:00 -0000 From: carlo@alinoe.com Reply-To: carlo@alinoe.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/8419: Erroneous warning: left shift count >= width of type X-SW-Source: 2002-10/txt/msg01385.txt.bz2 List-Id: >Number: 8419 >Category: c++ >Synopsis: Erroneous warning: left shift count >= width of type >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Oct 31 20:46:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: carlo@alinoe.com >Release: gcc-3.2 >Organization: >Environment: i686-gnu-linux >Description: Compiler gives a warning about a shift width for code that is never executed. This is highly annoying because there is no work around and I always use -Werror. I reported this as C++ front-end, because I think that this can only be a problem when the shift is a template parameter 'constant'; otherwise you can avoid the warning by simply not including the code that is never executed. >How-To-Repeat: Compile the following: void f() { static int const s = 32; unsigned int a = 0x12345678; if (s >= 32) a = 0; else // Now s is garanteed less than 32! a <<= s; } Or, more practical, compile this: template unsigned int f(unsigned int a) { if (shift >= 32) a = 0; else // Now s is garanteed less than 32! a <<= shift; } void g() { f<32>(0x12345678); } > g++-3.2 -v -c troep.cc Reading specs from /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs Configured with: /usr/src/gcc/gcc-3.2/configure --prefix=/usr/local/gcc-3.2 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-debug --enable-threads Thread model: posix gcc version 3.2 /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ troep.cc -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase troep.cc -version -o /tmp/ccqu1OxB.s GNU CPP version 3.2 (cpplib) (i386 Linux/ELF) GNU C++ version 3.2 (i686-pc-linux-gnu) compiled by GNU C version 3.2. ignoring nonexistent directory "/usr/local/gcc-3.2/i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/gcc-3.2/include/c++/3.2 /usr/local/gcc-3.2/include/c++/3.2/i686-pc-linux-gnu /usr/local/gcc-3.2/include/c++/3.2/backward /usr/local/include /usr/local/gcc-3.2/include /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/include /usr/include End of search list. troep.cc: In function `unsigned int f(unsigned int) [with unsigned int shift = 32]': troep.cc:12: instantiated from here troep.cc:7: warning: left shift count >= width of type as -V -Qy -o troep.o /tmp/ccqu1OxB.s GNU assembler version 2.12.90.0.15 (i386-redhat-linux) using BFD version 2.12.90.0.15 20020717 >Fix: >Release-Note: >Audit-Trail: >Unformatted: