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; }