Thread overview
Is this a new bug ?
Sep 24, 2022
test123
Sep 24, 2022
rikki cattermole
Sep 24, 2022
test123
Sep 24, 2022
Adam D Ruppe
September 24, 2022

If so please report it for me to bugs platform. I can not register one.

package {
    version(TEST) {
        static:
    } else {
       __gshared:
    }
    uint  test = 0;
}

ldmd2 -betterC -vtls -c ./test.d

./test.d(7): test is thread local

September 24, 2022
```d
version(all) {
    __gshared:
	uint test2;
}

uint test;
```

Output with -vtls:

```
Up to      2.079.1: Success with output: onlineapp.d(9): test is thread local
Since      2.080.1: Success with output: onlineapp.d(9): `test` is thread local
```

Looks fine to me.

September 24, 2022
On Saturday, 24 September 2022 at 07:11:12 UTC, rikki cattermole wrote:
> ```d
> version(all) {
>     __gshared:
> 	uint test2;
> }
>
> uint test;
> ```
>
> Output with -vtls:
>
> ```
> Up to      2.079.1: Success with output: onlineapp.d(9): test is thread local
> Since      2.080.1: Success with output: onlineapp.d(9): `test` is thread local
> ```
>
> Looks fine to me.

I think it should not be thread local.
September 24, 2022
On Saturday, 24 September 2022 at 06:13:55 UTC, test123 wrote:
> If so please report it for me to bugs platform.

This isn't a bug, the effect of keyword: things stop at the matching }.

(static if and version don't introduce a namespace scope, but they still follow this rule for the { colon: ... } blocks)

You need to duplicate your uint test2 variable inside those branches.
September 24, 2022

On Saturday, 24 September 2022 at 06:13:55 UTC, test123 wrote:

>

If so please report it for me to bugs platform. I can not register one.

package {
    version(TEST) {
        static:
    } else {
       __gshared:
    }
    uint  test = 0;
}

ldmd2 -betterC -vtls -c ./test.d

./test.d(7): test is thread local

static does nothing to module level variables.

Without attributes, test will be thread local. Your attributes are having no effect on the variable because they don’t apply outside the braces.

-Steve