[Issue 10108] Thread local slice to array literal references the same data
Simen Kjaeraas
simen.kjaras at gmail.com
Sat May 18 12:14:46 PDT 2013
On Sat, 18 May 2013 16:59:53 +0200, Sean Kelly <sean at invisibleduck.org>
wrote:
> This is expected because the global is __gshared and there's therefore
> no type protection from doing this. If you want safe sharing, make the
> global shared.
[snip]
>> __gshared int[] gArr = [1,2,3];
>> int[] arr = gArr;
Uhm, you are aware this is the Bugzilla newsgroup, right? Please reply in
Bugzilla.
Also, that's exactly what we're saying. This code has problems:
import core.thread;
int[] arr = [1,2,3];
void main() {
new Thread({arr[0] = 3;});
assert(arr[0] == 1);
}
And they are caused by the data inside arr being shared. This is unsafe,
unexpected (due to safety of other globals) and, we feel, goes against
the D ethos.
--
Simen
More information about the Digitalmars-d-bugs
mailing list