| Thread overview | |||||
|---|---|---|---|---|---|
|
November 30, 2012 Strange struct/atomicLoad behaviour | ||||
|---|---|---|---|---|
| ||||
Attachments:
| 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();
}
| |||
November 30, 2012 Re: Strange struct/atomicLoad behaviour | ||||
|---|---|---|---|---|
| ||||
Posted in reply to d coder | This is another bug with structures. Consider posting this to bugzilla. | |||
November 30, 2012 Re: Strange struct/atomicLoad behaviour | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Maxim Fomin Attachments:
| 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
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply