[Issue 11561] New: Built-in array .capacity returns 0 if array length is decreased

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 20 01:18:40 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11561

           Summary: Built-in array .capacity returns 0 if array length is
                    decreased
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: joseph.wakeling at webdrake.net


--- Comment #0 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2013-11-20 01:18:38 PST ---
Consider the following code:

    int[] arr;
    arr.length = 10;
    writeln(arr.length, "\t", arr.capacity);
    arr.length = 5;
    writeln(arr.length, "\t", arr.capacity);

Expected output:

    10    15
    5     n

... where n >= 5.

Actual output:

    10    15
    5     0

Since clearly the capacity of the array of length 5 _isn't_ 0, there is
something wrong in how the .capacity property is calculating its value after
the array length is reduced.

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


More information about the Digitalmars-d-bugs mailing list