Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Partial fix for Issue 14131 - va_copy is broken on posix X86_64
Browse files Browse the repository at this point in the history
  • Loading branch information
yebblies committed Feb 6, 2015
1 parent 8c13443 commit ee94dbd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/core/stdc/stdarg.d
Expand Up @@ -459,10 +459,19 @@ else version (X86_64)
{
}

import core.stdc.stdlib : alloca;

///
void va_copy(out va_list dest, va_list src)
void va_copy(out va_list dest, va_list src, void* storage = alloca(__va_list_tag.sizeof))
{
dest = src;
// Instead of copying the pointers, and aliasing the source va_list,
// the default argument alloca will allocate storage in the caller's
// stack frame. This is still not correct (it should be allocated in
// the place where the va_list variable is declared) but most of the
// time the caller's stack frame _is_ the place where the va_list is
// allocated, so in most cases this will now work.
dest = cast(va_list)storage;
*dest = *src;
}
}
else
Expand Down

0 comments on commit ee94dbd

Please sign in to comment.