[Issue 9495] Win64 vararg issue when first argument is > 8 byte

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jan 24 19:09:58 PST 2015


https://issues.dlang.org/show_bug.cgi?id=9495

--- Comment #5 from yebblies <yebblies at gmail.com> ---
(In reply to Benjamin Thaut from comment #4)
> Repo case?

>From https://github.com/D-Programming-Language/phobos/pull/2902

void printf(string format, ...)
{
    va_list ap;
    va_start(ap, format);
    vprintf(format, ap);
    va_end(ap);
}

va_start does something like `ap = (cast(void*)&format + size_t.sizeof)`, which
doesn't work as &format is the address of where the slice is stored on the
stack, not the address of where the low-level argument (a pointer to the slice)
was passed.

A workaround is to pass const(char)* only or pass ptr and length in distinct
parameters to avoid the >8 bytes case in the abi.

--


More information about the Digitalmars-d-bugs mailing list