Greetings
Here is a small piece of code that uses atomicLoad on a shared data, and behaves strange. Any clues whether this is a problem with atomicLoad(druntime) or with the DMD itself. I see the problem with the 2.060 release as well as with the github's current snapshot.
When I compile and run the code on my 64bit Ubuntu 12.10 machine, it prints out
Now, if I comment out the constructor of the Foo struct (which anyway I am not using), I get the right result that is
42
42
Any clues?
Regards
- Puneet
import core.atomic;
struct Foo {
public ulong _s = 0;
public this (ulong s) {
this._s = s;
}
}
auto foo () {
import std.stdio;
shared static Foo bar;
bar._s = 42;
writeln(bar._s);
shared Foo frop = atomicLoad(bar);
writeln(frop._s);
return frop;
}
void main() {
foo();
}