unsigned char a, b;
b = something();
a = ~b;
A static analyzer complained of truncation in the last line, presumably because b is prom
Lets take the case of Win32 machine.
Integer is 4 bytes and converting it to a char will result exactly as if left 3 bytes have been removed.
As you are converting a char to char, it doesn't matter to what is it being promoted to.
~b will add 3 bytes at the left change 0s to 1 and then remove... It does not affect your one right byte.
The same concept will be applicable for different architectures (be it 16 bit or 64 bit machine)
Assuming it to be little-endian