Comment by HexDecOctBin
6 days ago
I see, so would it would only be relevant to unions, or would adding a new node to a linked list or pushing another element in a dynamic array or setting a pointer to null also count?
6 days ago
I see, so would it would only be relevant to unions, or would adding a new node to a linked list or pushing another element in a dynamic array or setting a pointer to null also count?
As far as I understand, every change to indirections (pointers) is “shape unstable”, as it the update invalidates the old value, which causes every reference into that to be dangling (rather than merely modified).
Adding a new node at the end of a linked list, or more generally setting an unset pointer, would technically be shape-stable as you can’t have a reference into nothing. Generally pushing an element in a dynamic array is not shape-stable (the array can need to reallocate), although there would be workarounds e.g. a push which fails on lack of capacity would be shape-stable. Some sort of hybrid (e.g. rrb) would also work as extension consists of adding new node (possibly re-rooting the tree) but does not invalidate existing nodes.