"%f" format requires an argument of type
double. You're giving it an argument of type
int. That's why the behavior is undefined.
The standard does not guarantee that all-bits-zero is a valid representation of
0.0 (though it often is), or of any
double value, or that
double are the same size (remember it's
float), or, even if they are the same size, that they're passed as arguments to a variadic function in the same way.
It might happen to "work" on your system. That's the worst possible symptom of undefined behavior, because it makes it difficult to diagnose the error.
N1570 220.127.116.11 paragraph 9:
... If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.
Arguments of type
float are promoted to
double, which is why
printf("%f\n",0.0f) works. Arguments of integer types narrower than
int are promoted to
int or to
unsigned int. These promotion rules (specified by N1570 18.104.22.168 paragraph 6) do not help in the case of