digitalmars.D.bugs - [Issue 15041] New: Pointer slice with one negative index throws
- via Digitalmars-d-bugs (23/23) Sep 11 2015 https://issues.dlang.org/show_bug.cgi?id=15041
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 puremagic.com Reporter: anoneuron 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 ) --
Sep 11 2015