I should have a different definition of "error" :-) What prints the first two times when you call f ? I get
1 -1216175936 134513787 1 2 134513787 1 2 3
for my three function calls.
What you see is deterrence from the earliest days of C, when people played unattended with their function calls.
All that happens is that you call the f function and print three values from the stack (yes, even if you only give one or two). What happens when you are not sure enough that your program will most likely just use what it was in any case, which usually leads to data problems when reading and a catastrophic write failure.
This is completely compiled, although very unreasonable C. And I mean that in a very real “undefined behavior” the meaning of the word (in particular, refers to C99: “If the expression denoting the function to be called is a type that does not include a prototype ,. .. if the number of arguments is not equal to the number of parameters, the behavior is undefined ").
You should really provide fully formed function prototypes, such as:
void f(int,int,int);
so that your compiler takes this problem and uses ellipses ( ... ) in variable parameters.
Aside, what usually happens under the covers is that the calling function starts from the stack, like:
12345678 11111111
and pushes (for example) two values onto the stack, so that it ends like this:
12345678 11111111 2 1
When the called function uses the first three values on the stack (since it wants to), it discovers that it has 1 , 2 and 11111111 .
It does what it needs to do and then returns, and the calling function clears these two values from the stack (this is called a strategy that calls a good call). Woe to everyone who tries to do this with their trustworthy strategy :-) although this is rather unusual in C, as it makes variable argument functions like printf little harder to do.