Bug 20774 – Static arrays passed as dynamic arrays over varargs

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2020-04-26T15:36:14Z
Last change time
2024-12-13T19:08:20Z
Assigned to
No Owner
Creator
Iain Buclaw
Moved to GitHub: dmd#19697 →

Comments

Comment #0 by ibuclaw — 2020-04-26T15:36:14Z
This causes a mismatch between the caller and va_arg. Sample program: ``` void testVariadic(T)(int nargs, ...) { import std.stdio; foreach(i; 0 .. nargs) { auto arg = va_arg!T(_argptr); writeln(arg); } } alias StaticArray = int[4]; void test7() { StaticArray a0 = 0; StaticArray a1 = 1; StaticArray a2 = 2; testVariadic!StaticArray(3, a0, a1, a2); } ``` This prints: [4, 0, -1008992768, 32764] [4, 0, -1008992736, 32764] [4, 0, -1008992704, 32764]
Comment #1 by robert.schadek — 2024-12-13T19:08:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19697 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB