[Issue 20774] New: Static arrays passed as dynamic arrays over varargs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 26 15:36:14 UTC 2020
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 at puremagic.com
Reporter: ibuclaw at 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]
--
More information about the Digitalmars-d-bugs
mailing list