Re:Some things every C programmer should know about C (2002)
by int_19h on Wednesday December 11, 2019 @11:29PM
(#21769278)
Interesting. Yeah, you're right, int has to be at least 16-bit by the spec.
But, again, this would only manifest in expressions where you mix operators, or try to assign the result to a variable of a broader type. So (a+b+c) could still be evaluated entirely in 8 bits without becoming non-conforming, if target is a char, and ditto for (a-b-c) etc. So long as you know that only the last 8 bits of the result is all that matters, the promotion can be disregarded. It's only when you apply some other operator - multiplication, division, bit shift, or comparison - to the intermediate result that you can observe the increased width. But that doesn't actually happen all that often.
(Conversely, it might also mean that it is not conforming, but there are relatively few practical cases where it actually manifests.)
But, again, this would only manifest in expressions where you mix operators, or try to assign the result to a variable of a broader type. So (a+b+c) could still be evaluated entirely in 8 bits without becoming non-conforming, if target is a char, and ditto for (a-b-c) etc. So long as you know that only the last 8 bits of the result is all that matters, the promotion can be disregarded. It's only when you apply some other operator - multiplication, division, bit shift, or comparison - to the intermediate result that you can observe the increased width. But that doesn't actually happen all that often.
(Conversely, it might also mean that it is not conforming, but there are relatively few practical cases where it actually manifests.)