is my code to get CTFE instantiated object valid D ?
ag0aep6g via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat May 28 08:39:44 PDT 2016
On 05/28/2016 10:34 AM, Mike Parker wrote:
> On Saturday, 28 May 2016 at 05:30:26 UTC, chmike wrote:
[...]
>> Is a static const Category c variable a TLS variable ?
>
> Yes. All variables are TLS unless explicitly marked with __gshared or
> shared.
I don't think that's true.
----
import core.thread;
import std.stdio;
int m;
const int c;
immutable int i;
void main()
{
printAddresses();
new Thread(&printAddresses).start();
}
void printAddresses() { writeln(&m, " ", &c, " ", &i); }
----
Prints (for example):
----
7F554F9E1710 695FF0 695FF4
7F554EDDA5D0 695FF0 695FF4
----
So there are two different `m`s, but the `c`s and `i`s have the same
address on both threads. Seems to me that `m` is in TLS, but `c` and `i`
are not.
More information about the Digitalmars-d-learn
mailing list