Bug 12602 – [CTFE] Changes to an array slice wrapped in a struct do not propogate to the original

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-20T09:59:00Z
Last change time
2014-04-21T13:31:32Z
Keywords
CTFE, pull
Assigned to
nobody
Creator
dmitry.olsh

Comments

Comment #0 by dmitry.olsh — 2014-04-20T09:59:39Z
Simplified code, shows difference between R-T and C-T: struct Result { uint[] source; } auto wrap(uint[] r) { return Result(r); } auto testWrap() { uint[] dest = [1, 2, 3, 4]; auto ra = wrap(dest[0..2]); auto rb = wrap(dest[2..4]); foreach (i; 0..2) rb.source[i] = ra.source[i]; return dest; } @system void main() { static y = testWrap(); auto y2 = testWrap(); import std.conv; assert(y == y2, text(y, " vs ", y2)); //[1, 2, 3 ,4] vs [1, 2, 1, 2] } Tested with DMD 9c34e808dd83ecf810a2f87c73c8d8a95e90b5cc
Comment #1 by k.hara.pg — 2014-04-21T06:29:09Z
Comment #2 by github-bugzilla — 2014-04-21T13:31:32Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a2f919ee8b421ec26905690875894f2702fb0acb fix Issue 12602 - [CTFE] Changes to an array slice wrapped in a struct do not propogate to the original https://github.com/D-Programming-Language/dmd/commit/d54b1c779165eefb51b9d05e2ffe357a9f3c6afa Merge pull request #3478 from 9rnsr/fix12602 Issue 12602 - [CTFE] Changes to an array slice wrapped in a struct do not propogate to the original