www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is this a new bug ?

reply test123 <test123 gmail.com> writes:
If so please report it for me to bugs platform. I can not 
register one.


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


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

./test.d(7): `test` is thread local
Sep 23 2022
next sibling parent reply rikki cattermole <rikki cattermole.co.nz> writes:
```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.
Sep 24 2022
parent test123 <test123 gmail.com> writes:
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.
Sep 24 2022
prev sibling next sibling parent Adam D Ruppe <destructionator gmail.com> writes:
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.
Sep 24 2022
prev sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
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.


 ```d
 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
Sep 24 2022