A breach of immutability due to memory implicit conversions to immutable without synchronisation, maybe??
John Colvin
john.loughran.colvin at gmail.com
Thu Nov 15 15:41:05 UTC 2018
Correcting the obvious typos:
int* foo() pure {
auto ret = new int; // A
*ret = 3; // B
return ret;
}
shared immutable(int)* g;
void bar() {
immutable(int)* d = null;
while (d is null)
d = g.atomicLoad!(MemoryOrder.raw);
assert(*d == 3); // D
assert(*d == 3); // E
}
void main() {
auto t = new Thread(&bar).start();
immutable(int)* a = foo();
g.atomicStore!(MemoryOrder.raw)(a); // C
t.join;
}
More information about the Digitalmars-d
mailing list