public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: carlo@alinoe.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/8419: Erroneous warning: left shift count >= width of type
Date: Thu, 31 Oct 2002 20:46:00 -0000	[thread overview]
Message-ID: <20021101043851.27742.qmail@sources.redhat.com> (raw)


>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 shift>
  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:


             reply	other threads:[~2002-11-01  4:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-31 20:46 carlo [this message]
2002-11-06 14:07 bangerth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021101043851.27742.qmail@sources.redhat.com \
    --to=carlo@alinoe.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).