[Issue 23494] New: C-style variadic functions not working correctly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 18 14:19:00 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23494
Issue ID: 23494
Summary: C-style variadic functions not working correctly
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ogion.art at gmail.com
extern (C) void variadic(int* p, int x, int y, int z, const char *fmt, ...) {
import core.stdc.stdarg;
import core.stdc.stdio;
va_list args;
va_start(args, fmt);
foreach (_; 0..2) {
char* c;
va_arg(args, c);
printf("%s\n", c);
}
va_end(args);
}
void main() {
variadic(null, 0, 0, 0, "%s %s", "one".ptr, "two".ptr);
}
This should print:
one
two
On Windows, this works correctly in a 32-bit build. When compiled with -m64
flag, this prints:
%s %s
one
Tinkering with parameters preceding `fmt` affects the output.
--
More information about the Digitalmars-d-bugs
mailing list