[Issue 15041] New: Pointer slice with one negative index throws 'Range violation'
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Sep 11 09:40:38 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15041
Issue ID: 15041
Summary: Pointer slice with one negative index throws 'Range
violation'
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: anoneuron at gmail.com
When slicing a pointer, if one (not both) of the indices is negative, it throws
a Range violation. Tested with DMD 2.068.1
example:
auto p = &"aaaaaaaaaaaaaaaaaaaaa"[5];
assert(p[-1] == 'a'); // no problem
assert(p[-3 .. -1] == "aa"); // no problem
assert(p[-1 .. 1] == "aa"); // 'Range violation'
( http://dpaste.dzfl.pl/3be7eb85483c )
--
More information about the Digitalmars-d-bugs
mailing list