[Issue 10108] Thread local slice to array literal references the same data

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 21 12:41:58 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10108



--- Comment #15 from Simen Kjaeraas <simen.kjaras at gmail.com> 2013-05-21 12:41:56 PDT ---
(In reply to comment #14)
>     import core.thread;
>     int[] arr = [1,2,3].dup;
> 
>     void main() {
>         auto t = new Thread({arr[0] = 3;});
>         t.start();
>         t.join();
>         assert(arr[0] == 1);
>     }
> 
> The .dup should fix the problem, as now each thread gets its own copy of the
> array, right?

It's still being done at compile time, so no. It basically creates a copy at
compile time, then stores that in the data segment instead of the original.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list