Artifact 099a0f380b34a14b725ee5e29572fb996cfa7b260fdd58e43697b056a5f77b29:

Wiki page [are AA value pointers invalidated by AA mutation?] by admin 2021-10-30 11:27:34.
D 2021-10-30T11:27:34.517
L are\sAA\svalue\spointers\sinvalidated\sby\sAA\smutation?
U admin
W 640
<h2>Are AA value pointers invalidated by AA mutation?</h2>

In other words, does this program run without error?

<div class="language-d"><verbatim>
void main() {
    int[int] aa = [1: 2];
    int* p = 1 in aa;
    foreach (i; 3 .. 10_000_000)
        aa[i] = i;
    assert(aa.length == 10_000_000 - 2);
    assert(aa[1] == 2);
    assert(p == (1 in aa));
}
</verbatim></div>

There's no error, despite it reallocating the AA after the pointer is taken, because the pointer is to an individually allocated bucket, rather than a pointer into the resized backing array.

[https://forum.dlang.org/post/slhne0$19t8$1@digitalmars.com|Discussion]
Z 6326f9c4cb40ab70f863a3e87065132b