www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13425] New: DList.linearRemove on last element returns


          Issue ID: 13425
           Summary: DList.linearRemove on last element returns non-empty
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: murphyslaw480 gmail.com

Created attachment 1417
  --> https://issues.dlang.org/attachment.cgi?id=1417&action=edit
The example above, in case you care to test it

If a range refers to the last element in a DList, I would expect linearRemove
to return an empty range. Instead it returns a non-empty range that appears to
access memory outside the list's bounds.


auto list = DList!int([1,2,3,4,5]);
auto r = list[].drop(4); // r is a view of the last element of list
assert(r.front == 5 && r.walkLength == 1);
r = list.linearRemove(r.take(1));
assert(r.empty); // fails

Sep 05 2014