@safe pointer value modification
Jacob Shtokolov
jacob.100205 at gmail.com
Sat Sep 8 17:01:33 UTC 2018
Hi,
According to the docs: https://dlang.org/spec/memory-safe-d.html
> Memory-safe code cannot use certain language features, such as:
>
> Casts that break the type system.
> Modification of pointer values.
> Taking the address of a local variable or function parameter.
So, modification of pointer values is prohibited (if I understand
this sentence correctly).
However, this code compiles (and will cause a segfault of
course): https://run.dlang.io/is/HrUKMy
import std.stdio;
@safe void main()
{
int *a;
*a = 10;
writeln(a);
}
I'm still learning D so very likely misunderstood something, but
isn't that a bug?
Thanks!
More information about the Digitalmars-d
mailing list