stdargs [va_start(), va_arg(), etc] broken on arm64?

Viewed 1761

I have a c-function that uses varadic arguments in a standard fashion, below a simplified example:

    void func(parameter,...) {
     va_list args;
     va_start(args, parameter);

     //process args
     v1 = va_arg(args,sometype);
     v2 = va_arg(args,sometype);
        ...
     vn = va_arg(args,sometype);

     va_end(args);
}


//call func

func(parameter, p1, p2, ..., pn);

On all devices armv7s and lower as well as all simulators including 64-bit simulator this succeeds and variable v1 to vn is assigned p1 to pn, but when this executes on arm64 it seems like the variadic list is backwards ( v1 = pn, v2 = pn-1, ..., vn = p1)

Is there any fix for this? Or did I miss the documentation describing this change?

Thanks

EDIT:

I failed to mention a key element to this issue that I didn't think to mention before. I was attempting to swizzle non-variadic functions with a generic variadic function.

Note: the compiler being used was Apple LLVM 5.0

3 Answers
Related