Pointers - Is it safe to point to invalid memory?

Monkyyy crazymonkyyy at gmail.com
Sat Aug 16 15:24:44 UTC 2025


On Saturday, 16 August 2025 at 11:56:43 UTC, Brother Bill wrote:
> It is obvious that reading or writing to invalid memory can 
> result in "undefined behavior".
> But is merely pointing to invalid memory "harmful"?
>
> The documentation states that going one past the last element 
> of a slice is acceptable.
> But is it also safe to go 10, 100 or 1000 items past the last 
> element of a slice?

The way D's gc works makes xor pointers invalid, so even sorta 
safe pointers are explicitly broken

Probably store whatever in an int

> The documentation states that going one past the last element

If you read that d makes string litterals c strings, that only 
string litterals. Most overflows are a crash and idk how your not 
running into that? Yourve ready enough go start syntax testing.


More information about the Digitalmars-d-learn mailing list