N1370 6.5.2.2p8, discussing function calls, says:
No other conversions are performed implicitly; in particular,
the number and types of arguments are not compared with those
of the parameters in a function definition that does not include
a function prototype declarator.
Taken literally, this implies that a compiler may not check whether the
arguments in a call match the parameters of a non-prototyped function,
regardless of what it does with the information.
For example:
#include <stdio.h>
int func(n)
int n;
{
return n + 1;
}
int main(void) {
printf("func(0.1) = %d\n", func(0.1));
return 0;
}
Clearly no diagnostic is required, and the implementation is not
required to convert the argument 0.1 from double to int.
But a strict reading of 6.5.2.2p8 (some might say an overly pedantic
reading) implies that a compiler may not even warn about the type
mismatch on the call, because it would have to compare "the number
and types of arguments" with "those of the parameters in a function
definition" in order to produce such a warning.
Suggestion: That paragraph should be reworded to remove the
prohibition on comparing arguments vs. parameters, while still
stating that any such comparison doesn't result in an implicit
conversion.
Off the top of my head:
No other conversions are performed implicitly; in particular,
the number and types of the parameters in a function definition
that does not include a function prototype declarator are
not considered.
It might be argued that the current wording is clear enough, and that
the introductory "No other conversions are performed implicitly;"
implies that the rest of the paragraph only in that context.
In my opinion, though, it could easily be read either way.
--
Keith Thompson (The_Other_Keith)
ks...@mib.org <
http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"