[Issue 6114] immutable class variable not properly initialized when the constructor initializing it is non-shared

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 7 07:09:23 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=6114

--- Comment #8 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to Steven Schveighoffer from comment #6)
> The example isn't exactly pointing out the error.
> 
> There are 2 problems here, one is an expectation that a non-shared static
> ctor might run before the shared one (it doesn't, the order is clearly
> defined). That's not really a bug.
> 
> The second is that immutable (shared) data is changing from one thread to
> the next.

Really. what this shows is a side effect of the fact that it's currently
possible to instantiate an object that's treated as shared in a non-shared,
static constructor. It's the fact that the compiler let's you initialize
non-local immutable variables in a non-shared, static constructor that's the
bug. And once that's fixed, this problem goes away.

> I think this should be closed as a dup of 4923.

They're different symptoms of the same bug. So, I have no problem with that.

--


More information about the Digitalmars-d-bugs mailing list