[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 11:47:24 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10108
Sean Kelly <sean at invisibleduck.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sean at invisibleduck.org
--- Comment #14 from Sean Kelly <sean at invisibleduck.org> 2013-05-21 11:47:20 PDT ---
So I thought I understood this:
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);
}
It looks like we have a thread-local reference "arr" to a __gshared array of
int, so I would expect the assert to fail. Except:
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? But the assert still fails. I suppose I should check the ASM,
but the codegen seems kind of broken here. Is a __gshared label being inferred
for arr because it's statically slicing __gshared data?
--
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