Printf wrong result passing a float type


Julia 0.6, because this result, what am I doing wrong?

julia> ccall(:printf, Cint, (Ptr{UInt8}, Cfloat), "%f\n", 2.5);


Variadic functions in C are weird, they may not have the same calling convention as normal arguments. In particular, you need to use Cdouble due to default convertions in this case.

julia> ccall(:printf, Cint, (Cstring, Cdouble), "%f\n", 2.5);


Also note that there’s still a calling convention mismatch in this case and the correct way is

ccall(:printf, Cint, (Cstring, Cdouble...), "%f\n", 2.5)

The uninitialized register value in rax seems to have the same effect in this case though…
We currently don’t have a good syntax for calling variadic functions with different types