https://issues.dlang.org/show_bug.cgi?id=14114

          Issue ID: 14114
           Summary: DMD optimizer defeats use of volatileLoad/Store with
                    error: null dereference in function
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: [email protected]
          Reporter: [email protected]

>From the NG, the following example written by Walter as a way to demonstrate
volatileLoad/volatileStore actually does not work with -O

example.d(4): Error: null dereference in function _D7example5Ports1BFZh
---
import core.bitop;

 struct Ports {
    static ubyte B() { return volatileLoad(cast(ubyte *)0x0025); } // error
here
    static void B(ubyte value) { volatileStore(cast(ubyte *)0x0025, value); }
  }

void main() {
  Ports.B = 7;
  auto foo = Ports.B;
}

--

Reply via email to