[Issue 13619] New: std.container.array capacity not updated when length increases

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Oct 15 01:23:41 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13619

          Issue ID: 13619
           Summary: std.container.array capacity not updated when length
                    increases
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: trivial
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: dlang at thedeemon.com

import std.container;

void main() {
  Array!int a; // empty Array
  a.length = 10; 
  // now payload is allocated, length is set to 10, but capacity is still 0!

  // try to append a value
  a ~= 1; // runtime error (assertion: capacity < length !)
}

Fix is trivial, Array.Payload.length setter must update _capacity field when it
reallocates data.

--


More information about the Digitalmars-d-bugs mailing list