Discussion Thread: DIP 1035-- at system Variables--Community Review Round 2
Paul Backus
snarwin at gmail.com
Tue Mar 2 21:41:40 UTC 2021
On Tuesday, 2 March 2021 at 20:46:17 UTC, Atila Neves wrote:
> Pointer types *can* be unsafe, if the values came from @system
> code. Otherwise they're perfectly safe. Slices (dynamic arrays)
> are slightly different because of the necessity of bounds
> checks. But deferencing a pointer is fine in @safe code - the
> possibilities are:
>
> * it came from the GC.
> * is the address of a module-level variable.
> * is a scoped address on the stack.
> * is null.
>
> Am I missing a case?
You are conflating types and values. Pointer *values* can be
either safe or unsafe, depending on what they point to. Pointer
*types* are always unsafe, because they include both safe and
unsafe values.
More information about the Digitalmars-d
mailing list