Thread local variables in betterC

Blatnik blatblatnik at gmail.com
Sun May 9 18:41:33 UTC 2021


Do thread local variables work in -betterC? Or maybe it's better 
to ask are they _supposed_ to work in -betterC?

Here's a simple test program:

```D
// test.d
auto a;

extern(C) void main() {
   printf("before... ");
   a = 42;
   printf("after");
}

import core.stdc.stdio;
```

And here is the output of compiling and running:

```
$ dmd -betterC test.d; ./test.exe
before... after

$ dmd -betterC -m64 test.d; ./test.exe
before... [program hangs for 3 seconds, and then exits without 
printing anything else]
```

So when I compile a 64-bit version, the program just hangs when 
writing to the thread local variable. But it does work when 
compiled for 32-bits. So what is the intended outcome here?


More information about the Digitalmars-d-learn mailing list