I have a class non-static member function, and it has variable arguments, I'm compiling on Visual Studio 2005, with the 64-bit runtime, on 64-bit Windows.
void Class::Foo(void* ptr,...)
{
va_list args;
va_start(args,ptr);
float f=va_arg(args,float);
va_end(args)
}
I'm expecting a float, I pass a float to the function. But when I debug - I don't get the float I've passed. In fact - it's being received by the function as a 64-bit double! I have to do this:
double d=va_arg(args,double);
float f=(float)d;
Now I know Win64 likes to pass parameters in registers, and casts floats when it does this, shouldn't a va_list always be on the stack?
According to most references, I should have just a clean stack full of the passed parameters.
My question is: is this correct behaviour, or a bug? And if it's a bug, is it my bug, or Microsoft's?
I have the defines WIN64 and _M_AMD64, and WIN32 is undefined.