No modification of pointer values in safe functions?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Jan 3 22:12:01 UTC 2018


On Wednesday, January 03, 2018 22:02:22 Mark via Digitalmars-d-learn wrote:
> The documentation says the modification of pointer values is not
> allowed in safe functions. Yet the following compiles fine on dmd:
>
> void main() @safe
> {
>   int* x = new int;
>   int* y = new int;
>   y=x;
> }
>
> Is this simply a compiler bug?

Where are you reading that in the documentation? There's nothing unsafe
whatsoever about assigning one pointer to another.

Now, pointer arithmetic is unsafe, and that's forbidden in @safe functions.
So, I suspect that you're ether misunderstanding the documentation and/or
the documentation isn't clear enough.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list