On Monday, 19 October 2015 at 18:16:15 UTC, Andrei Alexandrescu wrote:
Tangentially related: since when we allow field initialization with new? I was surprised to see that this works:

Since CTFE started supporting it... this might actually be an unintentional feature.

Since the initializer is in a static context, the right hand side gets CTFE'd, which means that actually points to an array in the data segment... the *same* array in the data segment for all initializations (the pointer is just blitted over with the rest of init), which might be a bit surprising.

I've seen a lot of people do this with classes not realizing it makes a static instance!

Reply via email to