Skip to content

Commit 7ea9ad7

Browse files
committed
docs: comment on volatile access to 0 in fn docs
1 parent 174038b commit 7ea9ad7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/core/src/ptr/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,9 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
17491749
///
17501750
/// Volatile operations are intended to act on I/O memory, and are guaranteed
17511751
/// to not be elided or reordered by the compiler across other volatile
1752-
/// operations.
1752+
/// operations. In addition, note that bit-address 0 is legal and can be used
1753+
/// when it's known to hold I/O memory, so using these operations on a null
1754+
/// pointer won't panic.
17531755
///
17541756
/// # Notes
17551757
///
@@ -1828,7 +1830,9 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
18281830
///
18291831
/// Volatile operations are intended to act on I/O memory, and are guaranteed
18301832
/// to not be elided or reordered by the compiler across other volatile
1831-
/// operations.
1833+
/// operations. In addition, note that bit-address 0 is legal and can be used
1834+
/// when it's known to hold I/O memory, so using these operations on a null
1835+
/// pointer won't panic.
18321836
///
18331837
/// `write_volatile` does not drop the contents of `dst`. This is safe, but it
18341838
/// could leak allocations or resources, so care should be taken not to overwrite

0 commit comments

Comments
 (0)