5536 – Array append with dollar op on 64-bit

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5536 - Array append with dollar op on 64-bit
Summary: Array append with dollar op on 64-bit
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
Reported: 2011年02月06日 18:20 UTC by Martin Nowak
Modified: 2015年06月09日 05:15 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2011年02月06日 18:20:48 UTC
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.


AltStyle によって変換されたページ (->オリジナル) /