digitalmars.D.bugs - [Issue 17364] New: Difference between slicing a slice and a
- via Digitalmars-d-bugs (36/36) May 01 2017 https://issues.dlang.org/show_bug.cgi?id=17364
https://issues.dlang.org/show_bug.cgi?id=17364 Issue ID: 17364 Summary: Difference between slicing a slice and a reference to a slice Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: kinke gmx.net DMD treats these 2 cases differently, while GDC works as expected and LDC is being fixed accordingly: ``` safe: int[] globalArray; ref int[] getSliceRef() { return globalArray; } int getLowerBound() { globalArray = [ 666 ]; return 0; } void main() { globalArray = [ 1 ]; auto r1 = globalArray[getLowerBound() .. $]; assert(r1 == [ 666 ]); globalArray = [ 1 ]; auto r2 = getSliceRef()[getLowerBound() .. $]; assert(r2 == [ 1 ]); // BUG, should be [ 666 ] } ``` --
May 01 2017