July 25, 2023
https://issues.dlang.org/show_bug.cgi?id=24056

          Issue ID: 24056
           Summary: const uninitialized data at module scope is not in TLS
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: spec, wrong-code
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: schveiguy@gmail.com

module-level data that is declared const is stored in the global segment, yet is editable from normal static constructors.

Either const data should be put into thread local storage, or they should not be editable from static ctors that aren't shared:

```d
import std.stdio;
import std.concurrency;
import core.thread;
const void * x;

static this()
{
    auto addr = cast(void*) Thread.getThis();
    writeln("this thread is ", addr);
    x = addr;
}

void main()
{
    writeln("Before spawning thread: ", x);
    static void foo(Tid owner) {
        send(owner, 1);
    }
    auto tid = spawn(&foo, thisTid);
    receive((int x) {});
    writeln("After spawning thread: ", x);
}
```

Output:

this thread is 55788EDF3628
Before spawning thread: 55788EDF3628
this thread is 7FC99E404000
After spawning thread: 7FC99E404000

--