[Issue 24436] a array be overwritten when other array be written
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 12 18:55:20 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24436
Tim <tim.dlang at t-online.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |regression
--- Comment #8 from Tim <tim.dlang at t-online.de> ---
Unfortunately the second commit has not fixed the problem. It can still be seen
with 3x3 arrays.
import std.stdio, core.memory;
void main()
{
int[][] array1, array2;
array1 = new int[][](3,3);
foreach (row; 0 .. 3)
{
foreach (col; 0 .. 3)
{
array1[row][col] = col+row*3;
}
}
GC.collect();
array2 = new int[][](3,3);
foreach (row; 0 .. 3)
{
foreach (col; 0 .. 3)
{
array2[row][col] = 100+col+row*3;
}
}
writefln("%(%s,%)", array1);
writefln("%(%s,%)", array2);
}
DMD 2.106.0:
[0, 1, 2],[3, 4, 5],[6, 7, 8]
[100, 101, 102],[103, 104, 105],[106, 107, 108]
DMD 2.107.1:
[100, 101, 102],[103, 104, 105],[6, 7, 8]
[100, 101, 102],[103, 104, 105],[106, 107, 108]
DMD 2.108.0:
[0, 1, 2],[100, 101, 102],[6, 7, 8]
[100, 101, 102],[103, 104, 105],[106, 107, 108]
--
More information about the Digitalmars-d-bugs
mailing list