import std.stdio;
import core.thread;
import core.time;

auto arr = new ubyte[1]; // THIS SHOULD NOT COMPILE

int main(string[] args)
    new Thread({

    new Thread({

    writefln("arr[0] = %s", arr[0]);
    return 0;

In fact, it works as it should. But this behavior confuses beginners. They expect each thread to work with its own copy of the TLS-array. I believe, such initialization of mutable TLS-variables should lead to a compilation error, as is done for classes:

class Foo {}
Foo foo = new Foo(); // doesn't compile

Reply via email to