Default argument promotions in C function calls

Upvoted AProgrammer’s answer—those are the real goods.

For those of you who are wondering why things are this way: in the dark ages before 1988, there was no such thing as a function prototype in classic “K&R” C, and the default argument promotions were instituted because (a) there were essentially “free”, as it costs no more to put a byte in a register than to put a word in a register, and (b) to cut down on potential errors in parameter passing. That second reason never quite cut it, which was why the introduction of function prototypes in ANSI C was the single most important change ever in the C language.

As to when default promotions kick in: default argument promotions are used exactly when the expected type of the argument is unknown, which is to say when there’s no prototype or when the argument is variadic.

Leave a Comment