Heap allocation and internal pointers

monarch_dodra monarchdodra at gmail.com
Sun Jan 19 08:18:03 PST 2014


What is the "stance" on objects that reside on the heap, and 
internal pointers?

I understand that for stack objects, it leads to data corruption, 
due to data being bit-moved when passed around.

But what about heap data? Currently, our GC doesn't move data 
around, but what if it did? Would internal pointers be a problem? 
How do java/C# handle such cases?

My usecase is pretty trivial: A linked list. This is often 
implemented as a "single" sentinel that serves as both 
pre-head/post-tail. When the list is empty, the sentinel simply 
points to itself.

Would this be legal in D? The alternative would simply be to have 
two separate sentinels. It wouldn't change the design much, but 
I'd like to avoid doing it if at all possible...


More information about the Digitalmars-d mailing list