On Monday, 18 November 2013 at 16:03:33 UTC, Namespace wrote:
On Monday, 18 November 2013 at 15:27:46 UTC, Maxim Fomin wrote:
I think there is bigger problem (and bigger memory error)
here. When you inside struct method load pointer to some field
you cannot rely that after leaving the method, the pointer
will be safe. Structs are almost often located in stack and
there are movable, which means that struct stack 'this'
pointer may change.
There is even issue in bugzilla with example when delegate
touches struct field and is invoked at some point later which
causes silent memory error because delegate pointer became
invalid.
So I should change it from C[8] to C[] = new C[8]; to be sure?
Yes.