Bug 14040 – Doesn't use assignment in slice

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-24T23:57:00Z
Last change time
2016-01-03T14:02:06Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
alphaglosined

Comments

Comment #0 by alphaglosined — 2015-01-24T23:57:58Z
Example code: import std.stdio; void main() { uint[] values = [0, 1, 2, 3, 4, 5, 6, 7]; uint offset = 2; writeln(values[offset .. offset += 2]); writeln(offset); } Outputs: [] 4 Expected output: [2, 3] 4 Works correctly in LDC 2.063.2 (thanks DPaste). Doesn't work in DMD 2.065 or 2.066.1
Comment #1 by bearophile_hugs — 2015-01-25T00:05:34Z
Code like this is ugly, if I see code like this I refactor it immediately: values[offset .. offset += 2] Into two lines like: values[offset .. offset + 2] offset += 2;
Comment #2 by k.hara.pg — 2015-01-26T14:19:46Z
(In reply to Richard Cattermole from comment #0) > Works correctly in LDC 2.063.2 (thanks DPaste). > Doesn't work in DMD 2.065 or 2.066.1 dmd 2.063 prints same output with 2.066. I guess that the behavior difference comes from the the difference of glue layer implementations of LDC and DMD (currently DMD, LDC, and GCC have their own glue layers to fit to each backends).
Comment #3 by k.hara.pg — 2015-01-26T15:18:20Z
https://github.com/D-Programming-Language/dmd/pull/4345 As far as I see, old versions of dmd have same behavior with git-head, so it's not a dmd regression. But, the current behavior is contrary to the deterministic evaluation order, so I think it should be fixed. Downgrade importance to 'blocker'.
Comment #4 by github-bugzilla — 2015-10-14T01:33:54Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4fe170a3a3f2d5c3a4751f2c3e90ac6380583aab fix Issue 14040 - Doesn't use assignment in slice If upr has any side effects, lwr should be copied to temporary always. https://github.com/D-Programming-Language/dmd/commit/13f41930d43825f5fa88dbfb994946b67160656e Merge pull request #4345 from 9rnsr/fix14040 Issue 14040 - Doesn't use assignment in slice
Comment #5 by github-bugzilla — 2016-01-03T14:02:06Z