www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10641] New: array alloc missing APPENDABLE/capacity info

http://d.puremagic.com/issues/show_bug.cgi?id=10641

           Summary: array alloc missing APPENDABLE/capacity info
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: monarchdodra gmail.com


--- Comment #0 from monarchdodra gmail.com 2013-07-14 09:32:48 PDT ---
When allocating for an array, only the last dimension will have D-array
semantics, with capacity info. When allocating an array via new, ALL dimensions
should have appendable info associated.

//----
void main()
{
    alias T0 = ushort;
    auto s0 = new T0[](10);
    assert(s0.capacity); //OK

    alias T1 = ushort;
    auto s1 = new T1[][](10, 10);
    foreach (e; s1)
        assert(e.capacity); //OK
    assert(s1.capacity);    //FAILS

    alias T2 = ushort[];
    auto s2 = new T2[][](10, 10);
    foreach (e; s2)
        assert(e.capacity); //OK
    assert(s2.capacity);    //FAILS

    alias T3 = ushort;
    auto s3 = new T3[][][](10, 10, 10);
    foreach (e; s3)
    {
        foreach (ee; e)
            assert(ee.capacity); //OK
        assert(e.capacity);      //FAILS
    }
    assert(s2.capacity); //FAILS
}
//----

All the above "FAILS" should pass.

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