Greetings<div><br></div><div>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.</div>
<div><br></div><div>When I compile and run the code on my 64bit Ubuntu 12.10 machine, it prints out </div><div><div>42</div><div>4294967296</div></div><div><br></div><div>Now, if I comment out the constructor of the Foo struct (which anyway I am not using), I get the right result that is </div>
<div>42</div><div>42</div><div><br></div><div>Any clues?</div><div><br></div><div>Regards</div><div>- Puneet</div><div><br></div><div><div>import core.atomic;</div><div><br></div><div>struct Foo {</div><div> public ulong _s = 0;</div>
<div> public this (ulong s) {</div><div> this._s = s;</div><div> }</div><div>}</div><div><br></div><div>auto foo () {</div><div> import std.stdio;</div><div> shared static Foo bar;</div><div> bar._s = 42;</div><div>
writeln(bar._s);</div><div> shared Foo frop = atomicLoad(bar);</div><div> writeln(frop._s);</div><div> return frop;</div><div>}</div><div><br></div><div>void main() {</div><div> foo();</div><div>}</div></div><div><br>
</div>