When I compile the following code with -m32 and -m64 i get a totally different result, the documentation suggests that they should be the same...

import core.stdc.stdarg, std.stdio;

void main() {
        foo(0,5,4,3);
}

void foo(int dummy, ...) {
        va_list ap;
                
        for(int i; i<10; ++i) {
                version(X86_64) {
                        va_start(ap, __va_argsave);
                }
                else version(X86) {
                        va_start(ap, dummy);
                }       
                else
                        static assert(false, "Unsupported platform");
                
                int tmp;
                va_arg!(int)(ap,tmp);
                writeln(ap," ", tmp);
        }
}

when compiled with -m32 I get:

FF960278 5
FF960278 5
FF960278 5
FF960278 5
FF960278 5

and with -m64 I get:

7FFFCDF941D0 5
7FFFCDF941D0 4
7FFFCDF941D0 3
7FFFCDF941D0 38
7FFFCDF941D0 -839302560

(the end stuff is garbage, different every time)

I'm uncertain, even after looking over the stdarg src, why this would happen. The correct output is all 5s obviously.

Reply via email to