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

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jan 25 05:17:17 PST 2015


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

--- Comment #7 from yebblies <yebblies at gmail.com> ---
(In reply to Benjamin Thaut from comment #6)
> But this is then a completely different issue. The page
> https://msdn.microsoft.com/en-us/library/ms235286.aspx states for the Win64
> calling convention:
> 
> "Any argument that doesn’t fit in 8 bytes, or is not 1, 2, 4, or 8 bytes,
> must be passed by reference."
> 
> That means the implementation of the argument passing is correct. The issue
> is va_start which relies on "format" _not_ beeing passed by reference, which
> is clearly not the case for win 64.

Basically.  va_start just does va = &lastNamedArg + sizeof(void*) 

> For a propper implementation on Win64 you could do:
> 
> va_list ap = cast(va_list)_argptr;
> 

I consider the varargs implementation to be broken so long as the portable
interface doesn't work.  I don't think _argptr works for extern(C) vararg
functions on win64, as the offset is calculated in the frontend where it is
impossible to get the address of the stack slot the struct reference is stored
in.

> 
> I also don't see any way to fix va_start other then maybe inline assembly or
> turning it into a compiler intrinsic.

Yes, I am working on turning it into a compiler intrinsic.

--


More information about the Digitalmars-d-bugs mailing list