I create a new project with : `dub init myproj`.
Then I change the source/app.d file with this :
`
import std.stdio;
import std.math;
import std.stdio;
import std.conv;
import std.format;
import std.math;
import std.algorithm;
import std.net.curl;
import std.json;
//import dlib.image;
import std.path;
import std.array;
import std.net.curl;
import core.stdc.stdlib;
import std.datetime;
import std.file;
//import opmix.dup;
import std.parallelism;
import std.exception;
import core.exception;
void main() {
int[] a = new int[] (0);
try {
// writeln(a[1]);
test();
} catch ( RangeError re) {
writeln("wrong");
} catch (Throwable T){
writeln("something else");
}
}
void test() {
int [] b = new int[0];
int c = b[4];
writeln(c);
}
`
I compile with : `dub build -b release --compiler=ldc2`
The result executing the compiled binary 'myproj' is is ( whether
`writeln (a[1])` is uncommented, or the `test()` function is
uncommented) some random number, usually negative with large
absolute value, such as `-1894658200` .
If this is embedded in a class, then the result is segfault.
Is this expected behavior?
Thank you.