Consider the following code: ------------------cut here--------------------- typedef unsigned int uint32; template <uint32 offset> int foo(uint32 x) { if (offset <= 1) { return x << offset; } else { // this branch is dead for offset = 0, but it still generates a warning return (x << (offset - 1)) + (x >> (32 - offset)); } } int main(int argc, char** argv) { return foo<0>(argc); } ------------------cut here--------------------- As noted in the comment, the "else" branch is dead code for the offset=0 instantiation, but (at r213772 on trunk) we still generate warnings for the shifts that are out of range in the offset=0 case: $ /home/bmoses/gcc-archive/213772/bin/g++ b16825807.cc -o b16825807 b16825807.cc: In instantiation of ‘int foo(uint32) [with unsigned int offset = 0u; uint32 = unsigned int]’: b16825807.cc:15:21: required from here b16825807.cc:9:15: warning: left shift count >= width of type return (x << (offset - 1)) + ^ b16825807.cc:10:15: warning: right shift count >= width of type (x >> (32 - offset)); ^ (This is also present in the google/gcc-4_9 branch, and thus I suspect present on upstream 4.9.1 although I have not yet tested it.) Google bug: 16825807
Dup of much older bug: 4210. *** This bug has been marked as a duplicate of bug 4210 ***