[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
Wed Jul 5 10:20:53 PDT 2017


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

--- Comment #5 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
Okay, self-contained example:

bug.d
--------
class C
{
}

immutable C theC;

static this()
{
    theC = new immutable C;
}
--------

test.d
--------
import bug;

shared static this()
{
    assert(theC !is null);
}

void main()
{
}
--------

The assertion fails, but if you make the static constructor in bug.d shared,
then it doesn't.

--


More information about the Digitalmars-d-bugs mailing list