assigment to null class object member compiled? is this a bug?

dangbinghoo dangbinghoo at gmail.com
Fri Oct 19 06:53:32 UTC 2018


hi,

why the code bellow compiles?

---
import std.stdio;
class A {
     int m;
}

void main() {
     A a;
     a.m = 1;
}
---

and running this code get:

`segmentation fault (core dumped)  ./test`

I consider this couldn't be compiled according to book <The D 
Programming Language>.

The latest dmd (2.082) and LDC2 behaves the same.


More information about the Digitalmars-d-learn mailing list