On Wednesday, January 03, 2018 22:25:16 Mark via Digitalmars-d-learn wrote: > On Wednesday, 3 January 2018 at 22:12:01 UTC, Jonathan M Davis > > wrote: > > 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 > > https://dlang.org/spec/function.html#safe-functions > > "The following operations are not allowed in safe functions: > > [...] > - No modification of pointer values. > [...]"
Then the spec needs to be clarified. Assignment is fine but other types of mutation are not. - Jonathan M Davis