Hi memory experts,
I'm looking into eliminating raw pointers to traceable DISALLOW_NEW objects (
crbug.com/389707047, note its visibility is limited due to possible security risk). While working on it, I heard that memory could move on any memory operations, and I hope you could help me to understand this in more detail to write safe code.
For example:
class Item {
DISALLOW_NEW();
};
struct Container : public GarbageCollected<Container> {
HeapVector<Item> items;
};
void Test(const Container& container) {
for (const auto& item : container.items) {
auto x = MakeGarbageCollected<X>(); // <-- Could this move memory?
item.Func();
}
}
If the `MakeGarbageCollected` could move the backing buffer of the `HeapVector`, `item.Func()` will be a bad memory access.
Is this something I need to worry about, or are there more detailed conditions on when memory could be moved?