`char' parameters: a follow-up/summary ( Long - but worth it :-) )

Sue Meloy sue at hpclsue.HP.COM
Sat Sep 10 04:08:18 AEST 1988



Rationale, 3.7.1:

Some current implementations rewrite the type of a (for instance) char
parameter as if it were declared int, sice the argument is known to be
passed as an int (in the absence of prototypes).  The Standard requires,
however, that the received argument be converted as if by assignment upon
function entry.  Type rewriting is thus no longer permissible.

     QUIET CHANGE

   Functions that depend on char or short parameter types being
   widened to int, or float to double, may behave differently.

The assignment conversion for argument passing often requires no executable
code.  In most twos-complement machines, a short or char is a contiguous
subset of the bytes comprising the int actually passed (for even the most
unusual byte orderings), so that assignment conversion is effected by
adjusting the address of the argument (if necessary) and rewriting its type.

Draft Standard, 3.7.1:

On entry to the function the value of each argument shall be converted to the
type its corresponding parameter, as if by assignment to the parameter.



More information about the Comp.lang.c mailing list