I came across strange, seemingly non-deterministic, behaviour today. I simplified it the best I could below. I entice you to run the following piece of code.
module app;
import std.stdio;
struct A {
float[1] vec;
this(float[1] n) {
this.vec = n;
}
}
void main(string[] args) {
A c = A([50.0f]);
writeln(c.vec[0]);
A b = A([50.0f]);
writeln(b.vec[0]);
c = A([50.0f]);
writeln(c.vec[0]);
}
This will print:
0
50
nan
My findings:
- The first initializer will always contain 0
- Initialization to another variable will yield the expected 50
- Reinitialization will always yield null
Am I missing something? Is this a bug? I have no idea what is wrong.
Thanks for you help,
- HN