On Tuesday, 15 August 2017 at 21:54:23 UTC, Steven Schveighoffer wrote:
On 8/15/17 5:27 PM, Arek wrote:
On Tuesday, 15 August 2017 at 10:37:08 UTC, Kagamin wrote:
Well, no wrapper is actually needed here:

[...]
The issue is that send cannot handle shared value types due to a bug in the implementation. In essence, there is no reason to send a shared A -- it's an unrelated copy and not actually shared.

You can send a shared reference to an A just fine:

static shared A a;

send(tid, &a); // works

You *should* be able to send a shared(A). There is no reason to disallow it. But again, it's not super useful.

Yes, I absolutely agree. The object may be shared due to other requirements and there is no reason to reject 'share' qualifier what I want to send/receive it.

This very simple code also doesn't compile:

shared struct S
{
     int i;

     ~this()
     {
     }
}

void main()
{
     shared s = shared S();
}

In general, shared structs with postblit and destructor make problems.

postblit should work.

It does look like destructors are a problem. It appears the compiler attempts to call the destructor while unshared.

-Steve

But I have no idea how and when the object loses its shared nature. Yes, it looks like a bug in dmd. ldc 1.3 doesn't complain in this case.

Arek

Reply via email to