This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/65830] New: -Wno-shift-count-negative -Wno-shift-count-overflow don't work with const ints
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Apr 2015 13:02:53 +0000
- Subject: [Bug c/65830] New: -Wno-shift-count-negative -Wno-shift-count-overflow don't work with const ints
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65830
Bug ID: 65830
Summary: -Wno-shift-count-negative -Wno-shift-count-overflow
don't work with const ints
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
When dealing with const ints, the warning can't be suppressed with
-Wno-shift-count-negative -Wno-shift-count-overflow.
A c-c++-common/ test case:
/* PR c/... */
/* { dg-do compile } */
/* { dg-options "-O -Wno-shift-count-negative -Wno-shift-count-overflow" } */
int
foo (int x)
{
const int a = sizeof (int) * __CHAR_BIT__;
const int b = -7;
int c = 0;
c += x << a; /* { dg-bogus "left shift count >= width of type" } */
c += x << b; /* { dg-bogus "left shift count is negative" } */
c += x >> a; /* { dg-bogus "right shift count >= width of type" } */
c += x >> b; /* { dg-bogus "right shift count is negative" } */
return c;
}