The compiler knows the prototype of sqrt
, so it can - and will - produce the code to convert an int
argument to double
before calling the function.
The same holds the other way round too, if you pass a double
to a function (with known prototype) taking an int
argument, the compiler will produce the conversion code required.
Whether the compiler warns about such conversions is up to the compiler and the warning-level you requested on the command line.
For the conversion int -> double
, which usually (with 32-bit (or 16-bit) int
s and 64-bit doubles
in IEEE754 format) is lossless, getting a warning for that conversion is probably hard if possible at all.
For the double -> int
conversion, with gcc and clang, you need to specifically ask for such warnings using -Wconversion
, or they will silently compile the code.