[Issue 24436] New: a array be overwritten when other array be written
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 11 12:42:15 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24436
Issue ID: 24436
Summary: a array be overwritten when other array be written
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: mixedavocado+dlang at gmail.com
exsample code (DMD64 v2.107.1)(windows 11 Home 22H2)
import std.stdio, core.memory;
void main()
{
int[][] array1, array2;
array1 = new int[][](2,2);
foreach (row; 0 .. 2)
{
foreach (col; 0 .. 2)
{
array1[row][col] = col+row*2;
}
}
GC.collect();
array2 = new int[][](2,2);
foreach (row; 0 .. 2)
{
foreach (col; 0 .. 2)
{
array2[row][col] = 100+col+row*2;
}
}
writefln("%(%s,%)", array1);
writefln("%(%s,%)", array2);
}
expected output
[0,1],[2,3]
[100,101],[102,103]
actual output
[102,103],[2,3]
[100,101],[102,103]
--
More information about the Digitalmars-d-bugs
mailing list