www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Issue 2584] New: GDC on ARM does not honor volatile

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2584

           Summary: GDC on ARM does not honor volatile
           Product: DGCC aka GDC
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: major
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn users.sf.net
        ReportedBy: default_357-line yahoo.de


In GDC on ARM, the following code

struct Test {
  uint* ptr;
  uint write(uint i) { volatile (*ptr) = i; return i; }
}

void main() {
  Test test; test.ptr = cast(uint*) 0xDEAD_BEEF;
  test.write(0); test.write(0); test.write(0);
  return;
}

generates this assembly: http://paste.dprogramming.com/dpep5uc3 .

Note how the 0 is only stored once, not thrice, in blatant violation of the
volatile.


-- 
Jan 13 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2584





------- Comment #1 from default_357-line yahoo.de  2009-01-13 05:31 -------
Sorry. Please disregard for now. I'm seeing conflicting results.


-- 
Jan 13 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2584





------- Comment #2 from default_357-line yahoo.de  2009-01-13 05:44 -------
Right. Here we go. I had testcased it incorrectly.

The code to reproduce the error is 


struct Test {
  uint* ptr;
  uint write(uint i) { volatile (*ptr) = i; return i; }
  static Test opCall() { // it has to be returned by a function call, otherwise
the error doesn't happen
    Test res;
    res.ptr = cast(uint*) 0xDEAF_D00D;
    return res;
  }
}

void main() {
  auto mat = Test();
  asm { " baz"; }; // added to make sure it's the correct assembly this time
  mat.write(0); mat.write(0); mat.write(0);
  return;
}

And the assembly is here http://paste.dprogramming.com/dpag1p5d


-- 
Jan 13 2009