Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9495: Fixes issue with variadic functions on win64 #1657

Merged
merged 4 commits into from
Mar 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/func.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ void FuncDeclaration::semantic3(Scope *sc)
p = v_arguments; // last parameter is _arguments[] p = v_arguments; // last parameter is _arguments[]
if (global.params.is64bit && global.params.isWindows) if (global.params.is64bit && global.params.isWindows)
{ offset += Target::ptrsize; { offset += Target::ptrsize;
if (p->storage_class & STClazy) if (p->storage_class & STClazy || p->type->size() > Target::ptrsize)
{ {
/* Necessary to offset the extra level of indirection the Win64 /* Necessary to offset the extra level of indirection the Win64
* ABI demands * ABI demands
Expand Down
31 changes: 31 additions & 0 deletions test/runnable/test9495.d
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,31 @@
// PERMUTE_ARGS:

import core.vararg;

int func1(int a, ...)
{
auto result = va_arg!int(_argptr);
return result;
}

void test9495a()
{
assert(func1(5, 12345678) == 12345678);
}

int func2(const(char)[] a, ...)
{
auto result = va_arg!int(_argptr);
return result;
}

void test9495b()
{
assert(func2("5", 12345678) == 12345678);
}

void main(string[] args)
{
test9495a();
test9495b();
}