Detect uninitialized class var access

rassoc rassoc at posteo.de
Sat Sep 24 13:17:19 UTC 2022


Recently I refactored some old code of mine, now utilizing classes instead structs, and I got hit 
by an uninitialized variable access pattern similar to the simplified example below.

How can we easily spot this? What other switches and safeguards are there?

 > dmd -dip1000 -debug -g -w

just crashes with `Error: program killed by signal 11` on linux and nothing else.

```d
import std;

@safe:

class Foo { int x; }

void main() {
     Foo f; // = new Foo;
     writeln(f.x);
}
```


More information about the Digitalmars-d-learn mailing list