§ 28.3 Pointers and the Garbage Collector

kdevel kdevel at vogtner.de
Sun Apr 7 11:41:57 UTC 2019


On Sunday, 7 April 2019 at 10:17:53 UTC, AltFunction1 wrote:
> On Sunday, 7 April 2019 at 10:05:26 UTC, kdevel wrote:
>> In § 28.3 Pointers and the Garbage Collector [1] we read
>>
>>    Do not add or subtract an offset to a pointer such that the 
>> result points
>>    outside of the bounds of the garbage collected object 
>> originally allocated.
>>
>> [...]
>
> No the foo() code would work in D too but in D since we have a 
> true array type with ptr+length you should not write this kind 
> of code, which is not @safe BTW.

I appreciate your constructive reply. What about the formal 
validity wrt. to
the documentation? Is char *e = p + 10; outside of the bounds of 
the garbage collected object? Does for (q = p; q < e; ++q) depend 
on the ordering of pointers?


More information about the Digitalmars-d-learn mailing list