[Issue 14131] New: va_copy is broken on posix X86_64
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Feb 6 02:49:32 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14131
Issue ID: 14131
Summary: va_copy is broken on posix X86_64
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Keywords: wrong-code
Severity: major
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: yebblies at gmail.com
This code fails on posix X86_64 because va_copy doesn't properly copy the
argument pointer, instead aliasing the original.
void copya(int a, string format, ...)
{
va_list ap;
va_start(ap, format);
va_list ap2;
va_copy(ap2, ap);
auto a1 = va_arg!int(ap);
auto a2 = va_arg!int(ap);
auto a3 = va_arg!int(ap);
assert(a1 == 0x11111111);
assert(a2 == 0x22222222);
assert(a3 == 0x33333333);
auto b1 = va_arg!int(ap2);
auto b2 = va_arg!int(ap2);
auto b3 = va_arg!int(ap2);
assert(b1 == 0x11111111);
assert(b2 == 0x22222222);
assert(b3 == 0x33333333);
va_end(ap);
va_end(ap2);
}
void testCopy()
{
copya(0, "", 0x11111111, 0x22222222, 0x33333333);
}
--
More information about the Digitalmars-d-bugs
mailing list