Bug 5536 – Array append with dollar op on 64-bit

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2011-02-06T18:20:00Z
Last change time
2015-06-09T05:15:07Z
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2011-02-06T18:20:48Z
import std.stdio; void main() { int[] as = [111, 666]; writeln(as); as ~= as[$ - 2]; //!<- doesn't append 111 but the one right to it writeln(as); //! subtracting one more works correctly int[] bs = [111, 666]; writeln(bs); bs ~= bs[$ - 3]; writeln(bs); //! fetches memory outside of array int[] cs = [111]; auto mem = *(&cs[0] + 1); writeln(cs); cs ~= cs[$ - 1]; writeln(cs); assert(cs[1] == mem); } ----- !!! 64-bit specific error !!! Assign appending using the dollar op fetches the wrong value. Behaves as if the array length is updated before evaluating the dollar op.
Comment #1 by bugzilla — 2011-02-06T23:12:35Z