`char' parameters: a follow-up/summary

Doug Gwyn gwyn at smoke.ARPA
Fri Sep 9 17:25:44 AEST 1988


In article <13460 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>(/Word/ denotes italics; \S is a section symbol.)  No mention is made
>of `promotion' of the types of arguments; indeed, this section appears
>to revoke the note in K&R 1st ed. that promotes float argument
>declarations to double.  (Personally, I think that this is a good
>thing.)

Remember, this discussion was specifically about behavior in the
absence of prototypes, i.e. "old style" functions.  Section 3.3.2.2
of the dpANS specifies that the "default argument promotions" (which
include integral promotions as well as float->double) are performed
on the arguments in a function call.  This much agrees with K&R I;
it is impossible to pass a char to an old-style function (it gets
widened to int before reaching the function).

What happens at the start of the function is different between many
existing implementations and dpANS C; the dpANS does not allow type
rewriting (where a parameter defined as "char" gets treated as though
it had been defined as "int").  This is noted as a "QUIET CHANGE" in
the Rationale document, which you should refer to for more details.

The only safe, portable way to have written such old-style functions
was to define the parameter as the widened type that was actually
passed, e.g. int instead of char.



More information about the Comp.lang.c mailing list