import std.stdio; void main() { uint[] foo = [1,2,3,4,5]; ubyte[] bar = [1,2,3,4]; foo ~= bar; writeln(foo); // 1 2 3 4 5 67305985 foo.length = 5; ulong[] baz = [1,2,3,4]; foo ~= baz; writeln(foo); // 1 2 3 4 5 1 0 2 0 3 0 4 0 }
*** Bug 2910 has been marked as a duplicate of this bug. ***
*** Bug 2912 has been marked as a duplicate of this bug. ***
Also, this doesn't happen only for array literals. Here, I .dup the literals to make sure they're allocated like "normal" arrays and it still happens. import std.stdio; void main() { uint[] foo = [1U,2,3,4,5].dup; ubyte[] bar = [cast(ubyte) 1,2,3,4].dup; foo ~= bar; writeln(foo); // 1 2 3 4 5 67305985 foo.length = 5; ulong[] baz = [1UL,2,3,4].dup; foo ~= baz; writeln(foo); // 1 2 3 4 5 1 0 2 0 3 0 4 0 }
Could this be a regression?
Fixed a long time ago.