//////////////// test.d ////////////////
struct T
{
ubyte[16] data;
}
void assignZero(T)(ref T dst)
{
dst[] = 0;
}
static test =
{
T r;
r.data.assignZero();
return r;
}();
////////////////////////////////////////
dmd v2.094.2 gives the following error message when compiling:
test.d(14): called from here: assignZero(r.data)
test.d(16): called from here: (*function () pure nothrow @nogc @safe => r)()
Error: unknown, please file report on issues.dlang.org
Comment #1 by tim.dlang — 2020-12-20T16:29:48Z
See also issues 20684 and 20753.
Comment #2 by b2.temp — 2023-01-08T19:47:17Z
reduced and rewritten to track the issue better:
```
struct T
{
ubyte[1] data;
}
void assignZero(ref ubyte[1] dst)
{
dst[] = 0; // dst[0 .. 1] = 0; eliminates the ICE
}
int getInit()
{
T r;
assignZero(r.data);
return 0;
}
enum int test = getInit();
```
The problem seems to be related to CTFE + the slice assign lo and hi indexes + ref parameter.
Comment #3 by robert.schadek — 2024-12-13T19:13:34Z