www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19171] New: Array!bool range slicing has invalid assert

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

          Issue ID: 19171
           Summary: Array!bool range slicing has invalid assert
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: schveiguy yahoo.com

assert is as follows:

 assert(
                _a <= low && low <= high && high <= _b,
                "Using out of bounds indexes on an Array"
            );

Where _a and _b are the low and high indexes into the original array, where
`low` and `high` are the indexes passed into the range.

Instead it should be:

low <= high && high <= (_b - _a)

as the index is 0 based, not based on _a.

--
Aug 15 2018