Heap allocation and internal pointers
Steven Schveighoffer
schveiguy at yahoo.com
Mon Jan 20 11:41:28 PST 2014
On Mon, 20 Jan 2014 14:22:34 -0500, monarch_dodra <monarchdodra at gmail.com>
wrote:
> On Monday, 20 January 2014 at 12:27:41 UTC, Dicebot wrote:
>> Quick dlang.org investigation has found this:
>>
>> http://dlang.org/phobos/std_exception.html#.pointsTo
>>
>> Note:
>> Evaluating pointsTo(x, x) checks whether x has internal pointers. This
>> should only be done as an assertive test, as the language is free to
>> assume objects don't have internal pointers (TDPL 7.1.3.5).
>>
>> I guess you may want to check mentioned TDPL part ;)
>
> Yeah, I remember the pull that added that comment. As a matter of fact,
> it was I that brought up said part in the original pull.
>
> It basically says "dmd assumes no internal pointers for its move
> semantics" :/
Um.. that should only apply to stack-allocated items. Heap allocated items
are fine to point to themselves, even structs.
Consider that cycles are allowed, and planned for, in the GC. An internal
pointer is essentially a 1 element cycle!
A simple logical evaluation of how a moving GC would work reveals that it
should update internal pointers as well as all other pointers.
-Steve
More information about the Digitalmars-d
mailing list