Pointers - Is it safe to point to invalid memory?
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sat Aug 16 15:44:45 UTC 2025
On 17/08/2025 3:44 AM, Brother Bill wrote:
> On Saturday, 16 August 2025 at 15:30:43 UTC, H. S. Teoh wrote:
>> On Sat, Aug 16, 2025 at 03:24:55PM +0000, Brother Bill via
>> Digitalmars-d-learn wrote: [...]
>>> So a good D developer should not store an invalid pointer address
>>> into a pointer, with the single exception of storing a pointer
>>> address just past a slice or array.
>>
>> Where does it say this in the spec? Because this is wrong.
>>
>> D arrays carry length with them; they do not rely on pointers pointing
>> past the allocated memory region.
>>
>>
>> T
>
> Source: Programming in D book, page 432, chapter 68.8
> Quote: It is valid to point at the imaginary element one past the end of
> an array.
That is not the spec, the book is wrong.
More information about the Digitalmars-d-learn
mailing list