Mon May 23 16:59:12 CEST 2011
Automatic casting and overflow
Something I always do explicitly because I can't remember the rules:
char i = 255;
int j = i + 1;
Does i get cast from char -> int before the addition, or after? Where
is this made explicit?
Section 2.7 Type Conversions in K&R is quite explicit:
When an operator has operands of different types, they are converted
to a common type according to a small number of rules. In general,
the only automatic conversions are those that convert a ``narrower''
operand into a ``wider'' one without losing information [...]