[Issue 9099] segfault while returning an atomicLoad value

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 30 06:48:26 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9099



--- Comment #1 from Puneet Goel <puneet at coverify.org> 2012-11-30 06:48:25 PST ---
This is related. The result printed out by the code on my Ubuntu amd64 machine
is
42
4294967296

Upto version dmd-2.059, it correctly prints 42 and 42.

When the "this" constructor for Foo is commented out again the results are
correctly printed out as 42 and 42.


// 
import core.atomic;

struct Foo {
  public ulong _s = 0;
  // atomicLoad gives out wrong value when this (constructor) is defined
  public this (ulong s)  {
    this._s = s;
  }
}

auto foo () {
  import std.stdio;
  shared static Foo bar;
  bar._s = 42;
  writeln(bar._s);
  atomicStore(bar, bar);
  shared Foo frop = atomicLoad(bar);
  writeln(frop._s);
  return frop;
}

void main() {
  foo();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list