---
import std;
struct zero
{
char x;
~this() { writefln("~zero() 0x%x '%s' @ 0x%s", x, x, &this); }
}
void main()
{
std.parallelism.defaultPoolThreads(1);
writeln(">>>");
auto wls = taskPool.workerLocalStorage!zero;
writeln("<<<");
writeln(wls);
}
---
output:
---
% dmd -run test.d
>>>
~zero() 0x0 '' @ 0x7FFCD1506318
~zero() 0x0 '' @ 0x7FFCD1506318
~zero() 0xff '�' @ 0x7FFCD1506358
~zero() 0xff '�' @ 0x7FFCD15063E9
~zero() 0xff '�' @ 0x7FFCD1506358
~zero() 0xff '�' @ 0x7FFCD15063E9
<<<
WorkerLocalStorage!(zero)(std.parallelism.TaskPool, 2, 64, 7FA458F92010, 7FA458F94040)
---
relevant line: https://github.com/dlang/phobos/blob/v2.098.0/std/parallelism.d#L3095
it seems to be calling T's destructor on the newly allocated memory when setting it to T.init. i don't think it should be calling the destructor at all when there couldn't have been a valid T in the memory there
Comment #1 by robert.schadek — 2024-12-01T16:39:34Z