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.
Comment #3 by dlang-bot — 2021-04-07T10:00:17Z
@WalterBright updated dlang/dmd pull request #12396 "fix Issue 14114 - Allow volatileLoad/Store to access null location" fixing this issue: - fix Issue 14114 - Allow volatileLoad/Store to access null location https://github.com/dlang/dmd/pull/12396
Comment #4 by dlang-bot — 2021-04-07T20:44:31Z
dlang/dmd pull request #12396 "fix Issue 14114 - Allow volatileLoad/Store to access null location" was merged into master: - ab9e3c3d1bb3def7315b212f2da07eaf7d3ed609 by Walter Bright: fix Issue 14114 - Allow volatileLoad/Store to access null location https://github.com/dlang/dmd/pull/12396