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