Static inline field initialization

Moritz Maxeiner via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 23 04:06:41 PDT 2017


On Wednesday, 23 August 2017 at 09:12:19 UTC, Kagamin wrote:
> On Tuesday, 22 August 2017 at 16:28:43 UTC, Moritz Maxeiner 
> wrote:
>> class Test
>> {
>>     ubyte[] buf = new ubyte[1000]; // thread local storage, 
>> instances in the same thread refer to the same static array
>> }
>
> Dynamic initialization is done by constructor:
>
> [...]
>
> It's also unambiguous as to how it works.

I am aware, as I have pointed out the same in the above, but the 
post you quote is explicitly not about dynamic initialization 
(i.e. the result of new points into the heap), but about static 
initialization (the result of new points into sections of the 
binary format).
Specifically, it's about static initialization done for variables 
put into classic global storage (e.g. ELF sections .data/.bss) 
and variables put into thread local storage (e.g. ELF sections 
.tdata/.tbss).


More information about the Digitalmars-d mailing list