www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2892] New: Appending U[] to T[] where U : T but U != T yields corrupted results

reply d-bugmail puremagic.com writes:
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
}


-- 
Apr 24 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2892


clugdbug yahoo.com.au changed:

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





*** Bug 2910 has been marked as a duplicate of this bug. ***


-- 
Apr 29 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2892


dsimcha yahoo.com changed:

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





*** Bug 2912 has been marked as a duplicate of this bug. ***


-- 
Apr 29 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2892






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
}


-- 
Apr 29 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2892






Could this be a regression?


-- 
Apr 29 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2892


David Simcha <dsimcha yahoo.com> changed:

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



Fixed a long time ago.

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