http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59852
--- Comment #7 from Josh Triplett <josh at joshtriplett dot org> --- (In reply to Josh Triplett from comment #4) > Also note that arithmetic operations between a bitwise and a known-zero > value do not warn. > > The warning on ~ of a value smaller than int only occurs if the value is not > subsequently stuffed back into the same bitwise type. For instance, this > does not warn: > > typedef unsigned short __attribute__((bitwise)) le16; > > le16 i, j; > > le16 k = ~i | j; To elaborate on this with some implementation details of Sparse: applying ~ to a bitwise type smaller than an int produces a value of a corresponding bitwise type with the added attribute "fouled". Bitwise operations propagate the fouled bit if either operand has it, without warning. == and != will warn about fouled types. Assignments or conversions to the original unfouled bitwise type will work without warning, discarding the fouled bit. And any arithmetic operation that would warn about a bitwise type will warn about a fouled type, complaining that the type degraded to "int".