Bug 23494 – C-style variadic functions not working correctly

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2022-11-18T14:19:00Z
Last change time
2024-12-13T19:25:44Z
Assigned to
No Owner
Creator
Georgy Markov
Moved to GitHub: dmd#20186 →

Comments

Comment #0 by ogion.art — 2022-11-18T14:19:00Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:25:44Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20186 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB