https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55095
--- Comment #14 from David Binderman <dcb314 at hotmail dot com> --- (In reply to Marek Polacek from comment #13) > Implemented for GCC 6. Suggestion for improvement, based on compiling Linux kernel. 3901 Wshift-overflow warning messages were produced, of which 3780 (97% of them) were for the sign bit only. Suggest don't produce the warning if the shift overflow is for the sign bit only. Rationale: Folks typically write code like this (x & 0x1f) << 27 and don't expect warning messages. With the new warning, they do get a message. Technically correct, but I am not sure of the value. Of course, the correct source code is (x & (unsigned) 0x01f) << 27 but asking folks to correct thousands of warning messages immediately is probably asking too much. Another way to implement my proposed change is to only produce a warning if the shift overflow is 2 or more bits. The one bit case can be done later, after all the cases where gross shift overflow occurs. I just checked clang, and it already does what I am suggesting.