Hello,
I am interesting D as memory safe language (maybe SafeD?) and have written very simple code:
@safe
import std.stdio;
class A {
this() {
writeln("[A] Constructor");
}
~this() {
writeln("[A] Destructor");
}
void run() {
writeln("[A] run");
}
}
int main()
{
A a;
a.run();
writeln("Hello, world!");
return 0;
}
Output is:
C:\Software\D\dmd2\windows\bin64\dub.exe run --build-mode separate
Starting Performing "debug" build using C:\Software\D\dmd2\windows\bin64\dmd.exe for x86_64.
Building dlang-app ~master: building configuration [application]
Linking dlang-app
Running dlang-app.exe
Error Program exited with code -1073741819
Process finished with exit code 2
So I don't see any errors or warnings from compiler when I use uninitialized variable a
and don't see any exception with backtrace in runtime (application is build in debug mode).
Is it expected behavior?
Looks like it is not very safe approach and can lead to very unpleasant memory errors...