On Monday, 16 July 2018 at 22:16:10 UTC, Adam D. Ruppe wrote:
On Monday, 16 July 2018 at 22:08:34 UTC, Eric wrote:
This makes the compiler crash. Is it illegal code?

Yes, a struct can be moved at any time by the compiler which means pointers to it can be invalidated at random.

Unless you always allocate it externally yourself...

I know that. At the moment I disable the postblit and use an init():

class Test {
  List ls;

  this() {
    ls.init();
  }
}

But I want to be able to write something less verbose like:

class Test {
  List ls = 1;
}

And I was hoping a this(int) constructor would happen in place, not move things around.


Reply via email to