[Issue 18283] -dip1000 doesn't catch invalid local reference
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 23 04:14:55 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18283
--- Comment #1 from Mike Franklin <slavo5150 at yahoo.com> ---
Interestingly, `destroy` is an unsafe operation for classes.
import std.stdio;
class A
{
void hello() @safe { writeln("hello"); }
}
void main() @safe
{
A a = new A();
a.hello();
destroy(a); // onlineapp.d(12): Error: @safe function 'D main' cannot call
// @system function 'object.destroy!(A).destroy'
a.hello();
}
https://run.dlang.io/is/AwKBc3
But it's not an unsafe operation for pointers
import std.stdio;
struct A
{
int i;
void print() @safe { writeln(i); }
}
void main() @safe
{
A* a = new A();
a.print(); // OK
a.destroy();
a.print(); // Error!
}
https://run.dlang.io/is/Fm7qBR
I'm not sure what the language authors' intentions are, so I can't say whether
the bug is in SafeD, or in the implementation of `destroy`.
--
More information about the Digitalmars-d-bugs
mailing list