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.
https://github.com/D-Programming-Language/dmd/commit/f02795d86981f3b2560d4b1962dcea872daca484 https://github.com/D-Programming-Language/dmd/commit/835e7cfb6936bc796fa7857828dec5a07b2f604e
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル