Bug 2892 – Appending U[] to T[] where U : T but U != T yields corrupted results

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-04-24T20:25:00Z
Last change time
2015-06-09T01:26:25Z
Keywords
wrong-code
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2009-04-24T20:25:19Z
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 }
Comment #1 by clugdbug — 2009-04-29T10:31:42Z
*** Bug 2910 has been marked as a duplicate of this bug. ***
Comment #2 by dsimcha — 2009-04-29T15:19:13Z
*** Bug 2912 has been marked as a duplicate of this bug. ***
Comment #3 by dsimcha — 2009-04-29T15:26:05Z
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 }
Comment #4 by clugdbug — 2009-04-29T23:32:31Z
Could this be a regression?
Comment #5 by dsimcha — 2009-12-05T18:27:04Z
Fixed a long time ago.