Bug 14114 – Allow volatileLoad/Store to access null location
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-02T18:43:19Z
Last change time
2021-04-07T20:44:31Z
Keywords
backend, bare-metal, pull, rejects-valid
Assigned to
No Owner
Creator
Iain Buclaw
Comments
Comment #0 by ibuclaw — 2015-02-02T18:43:19Z
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;
}
Comment #1 by bugzilla — 2015-02-02T21:23:55Z
The optimizer is regarding as a "null" any value being dereferenced that is less than 4096.
Whether this is a bug or not is debatable.
Comment #2 by bugzilla — 2021-04-07T09:57:44Z
Decided the best fix was to allow volatile read/writes, as some systems do store things at null.