Does the spec preclude objects being movable by the GC?

Ben Davis entheh at cantab.net
Mon Feb 25 15:17:00 PST 2013


On 25/02/2013 23:15, Ben Davis wrote:
> Unless I'm mistaken, this page:
>
> http://dlang.org/garbage.html
>
> states that it's safe to use a union to share storage with a pointer, e.g.
>
> union U { void* ptr; int value }
>
> But that wouldn't be safe if the GC ever moved objects. Should the page
> be tweaked? Especially as further down on that page, it says that a
> moving garbage collector can be implemented if one follows the rules.

Actually I suppose it's possible for any object affected by that union 
to be pinned. Is that the intention?


More information about the Digitalmars-d mailing list