Aliases to mutable thread-local data not allowed [testable source code]

Simen Kjærås simen.kjaras at
Wed Mar 11 14:01:13 UTC 2020

On Wednesday, 11 March 2020 at 12:43:28 UTC, mark wrote:
> On Wednesday, 11 March 2020 at 12:22:21 UTC, Simen Kjærås wrote:
>> On Wednesday, 11 March 2020 at 09:29:54 UTC, mark wrote:
> [snip]
>> Fascinating. It works just fine when compiling for 32-bit 
>> targets with DMD on Windows, but not for 64-bit targets, nor 
>> when compiling with LDC. Apparently, this difference is due to 
>> DMD supporting 80-bit reals, and thus giving a different size 
>> to Variant (VariantN!20 on DMD on Windows, VariantN!16 or 
>> VariantN!32 elsewhere). There's a bug in VariantN that then 
>> causes the compilation to fail 
>> (
>> The issue at hand then, is that Deb is too big until that 
>> issue if fixed. The simple solution to this is to allocate Deb 
>> on the heap with new and pass pointers instead of instances 
>> directly. Since you are already calling .dup whenever you pass 
>> a Deb somewhere, you can simply modify .dup to return a Deb* 
>> and the receive function to receive a Deb*, and I think you 
>> should be good to go.
> I did that and it compiles & runs, but no Debs get added to the 
> collection.
> See -- 
> the 'mto' version is the one with your fixes.

Yeah, I forgot we cast to immutable to be able to send, so 
receive has to receive immutable(Deb)*, after which you can call 
deb.dup to get a mutable copy:

         (immutable(Deb)* deb) { debForName[] = deb.dup; },
         (DoneMessage m) { jobs--; }


More information about the Digitalmars-d-learn mailing list