Casts are just operators, like multiplication or shifts. When a function argument is an expression, it is evaluated like any other expression. So function((short) a);
is equivalent to:
short tmp_a = (short) a;
function(tmp_a);
in the same way that function(a*a);
is equivalent to:
int tmp_a = a*a;
function(tmp_a);
Note there are also implicit conversions involved in function calls. If the function has a prototype, arguments are converted to the declared types of the parameters. If there is no prototype, or an argument corresponds to the ...
part of a prototype, some default argument promotions are performed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…