DMD 1.001 release

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Jan 24 02:42:07 PST 2007


Walter Bright wrote:
> Tomas Lindquist Olsen wrote:
>> Let me clarify what I mean. Consider this code:
>>
>> import std.gc;
>>
>> void test()
>> {
>>     void[] buf = new void[1024];
>>     std.gc.hasNoPointers(ret.ptr);
>>     // invoking gc will not scan buf. ok
>>     buf.length = buf.length*2;
>>     // could invoking gc now potentially scan buf?
>> }
>>
>> I'm thinking how to make sure a void[] is _never_ scanned.
>> A somewhat realistic case for this would be (again) the std.file.read
>> function.
>> If we append some data to this buffer will the GC be smart enough to
>> know it still holds no pointers? That is even with the reallocation and
>> potential relocation.
> 
> It'll reallocate based on the type of buf, which is void[], so you'll 
> need to invoke gc.hasNoPointers again.

Shouldn't it copy pointer-ness from the original to the new array? That 
seems like the logical thing to do.
The same applies to concatenating arrays, though perhaps that should 
follow the rule "the new array contains pointers if either original 
array contained pointers".



More information about the Digitalmars-d-announce mailing list