Thread overview
[Issue 2892] New: Appending U[] to T[] where U : T but U != T yields corrupted results
Apr 25, 2009
d-bugmail
Apr 29, 2009
d-bugmail
Apr 29, 2009
d-bugmail
Apr 29, 2009
d-bugmail
Apr 30, 2009
d-bugmail
Dec 06, 2009
David Simcha
April 25, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2892

           Summary: Appending U[] to T[] where U : T but U != T yields
                    corrupted results
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: dsimcha@yahoo.com


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
}


-- 

April 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2892


clugdbug@yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au




------- Comment #1 from clugdbug@yahoo.com.au  2009-04-29 10:31 -------
*** Bug 2910 has been marked as a duplicate of this bug. ***


-- 

April 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2892


dsimcha@yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@metalanguage.com




------- Comment #2 from dsimcha@yahoo.com  2009-04-29 15:19 -------
*** Bug 2912 has been marked as a duplicate of this bug. ***


-- 

April 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2892





------- Comment #3 from dsimcha@yahoo.com  2009-04-29 15:26 -------
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
}


-- 

April 30, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2892





------- Comment #4 from clugdbug@yahoo.com.au  2009-04-29 23:32 -------
Could this be a regression?


-- 

December 06, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2892


David Simcha <dsimcha@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #5 from David Simcha <dsimcha@yahoo.com> 2009-12-05 18:27:04 PST ---
Fixed a long time ago.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------