On Mon, Dec 28, 2015 at 04:09:22PM -0800, Alex G. wrote:
Are you suggesting that an (unsigned) cast should be added? I doubt it would matter.
I'm suggesting to not rely on (0 - 4) to produce 0xfffffffc. The (unsigned) cast does not solve the C issue of writing a negative value into an unsigned type.
FYI, assigning "0 - 4" to an unsigned integer is not undefined. From the C11 spec, section 184.108.40.206:
1 When a value with integer type is converted to another integer type other than _Bool, if the value can be represented by the new type, it is unchanged.
2 Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.