On 7/10/16 9:02 AM, ag0aep6g wrote:
While messing with atomicLoad [1], I noticed that dmd lets me implicitly
convert values to/from shared without restrictions. It's in the spec
[2]. This seems bad to me.

I think you misunderstand the problem here. Conversion means changing the type.

Once you have loaded the shared data into a register, or whatever, it's no longer shared, it's local. Writing it out to another place doesn't change anything. It's once you add references into the mix where you may have a problem.

What I think you mean (and I think you realize this now), is that the actual copying of the data should not be implicitly allowed. The type change is fine, it's the physical reading or writing of shared data that can cause issues. I agree we should extend the rules to prevent this.

In other words:

shared int x;

void main()
{
   // ++x; // not allowed
   int x2 = x + 1; // but this is
   x = x2; // and it shouldn't be
}

-Steve

Reply via email to