With gcc\'s -Wconversion
warning, It looks like chars and shorts are implicitly converted to ints.
#include
#pragma GCC diagnostic w
According to the C standard (6.5.3.3), the integer promotions are performed on the operand of ~
and the result is of the promoted type. The integer promotions (6.3.1.1) basically say that all integer types smaller than int
are promoted to int
(if int
can represent all values of the original type) or unsigned int
(otherwise).