Today I stumbled across three issues with partial initialization of "static" arrays:
void main ()
{
char [7] b = [ 1: 'x' ]; // okay
char [7] a = [ 0: 'x' ]; // i1.d(4): Error: mismatched array lengths, 7 and 1
}
import std.stdio;
void main ()
{
char [7] c7 = [ 1: 'x' ];
writeln (cast (ubyte [7]) c7); // [255, 120, 255, 255, 255, 255, 255] okay
char [7] d7 = "x";
writeln (cast (ubyte [7]) d7); // [120, 0, 0, 0, 0, 0, 0] would have expected
// [120, 255, 255, 255, 255, 255, 255]
}
// i3.d
void main ()
{
string s = "x";
static assert (is (typeof (s) == typeof ("x")));
assert (s == "x");
char [7] c7 = s; // throws RangeError
}
$ dmd -g i3
$ ./i3
core.exception.RangeError@i3.d(7): Range violation
----------------
??:? _d_arrayboundsp [...]
i3.d:7 _Dmain [...]
Shall I file them to bugzilla?