On Thursday, 11 February 2016 at 04:31:12 UTC, cy wrote:

Oh, I get it. `as` is an array of 2 pointers to A objects, both pointers set to null. So I need to say like:

as[0..$] = new A();

before accessing .stuff on as[0].

Pedantically, no. It's an array of two class references. I don't think it's helpful to think of class references as pointers. That's just an implementation detail.


Still no clue why it segfaulted on the allocation though, rather than the statement with the null dereference. Hidden optimization?

You said,

removing "as[0].stuff = 42" causes the program to stop segfaulting!

Which indicates that was where the segfault was happening. The debugger was just stopping before that.

Reply via email to