digitalmars.D - Strange struct/atomicLoad behaviour
- d coder (35/35) Nov 30 2012 Greetings
- Maxim Fomin (2/2) Nov 30 2012 This is another bug with structures. Consider posting this to
- d coder (4/5) Nov 30 2012 Thanks for confirming. I have posted this to Bugzilla.
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
42
4294967296
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();
}
Nov 30 2012
This is another bug with structures. Consider posting this to bugzilla.
Nov 30 2012
On Fri, Nov 30, 2012 at 7:41 PM, Maxim Fomin <maxim maxim-fomin.ru> wrote:This is another bug with structures. Consider posting this to bugzilla.Thanks for confirming. I have posted this to Bugzilla. Regards - Puneet
Nov 30 2012








d coder <dlang.coder gmail.com>