digitalmars.D.bugs - [Issue 20774] New: Static arrays passed as dynamic arrays over varargs
- d-bugmail puremagic.com (39/39) Apr 26 2020 https://issues.dlang.org/show_bug.cgi?id=20774
https://issues.dlang.org/show_bug.cgi?id=20774 Issue ID: 20774 Summary: Static arrays passed as dynamic arrays over varargs Product: D Version: D2 Hardware: All OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ibuclaw gdcproject.org 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] --
Apr 26 2020