diff --git a/examples/bare4.rs b/examples/bare4.rs index 37dd6fc13605b0497402ad4e018f08f610cc9177..eee44e01d781e31e9a204d3547ae554704ae8010 100644 --- a/examples/bare4.rs +++ b/examples/bare4.rs @@ -36,8 +36,8 @@ use address::*; #[inline(always)] fn read_u32(addr: u32) -> u32 { - unsafe { core::ptr::read_volatile(addr as *const _) } - //core::ptr::read_volatile(addr as *const _) + //unsafe { core::ptr::read_volatile(addr as *const _) } + core::ptr::read_volatile(addr as *const _) } #[inline(always)] @@ -107,12 +107,14 @@ fn main() -> ! { // // What was the error message and explain why. // -// ** your answer here ** +// call to unsafe function is unsafe and requires unsafe function or block. +// This happens because the variable is volatile. // // Digging a bit deeper, why do you think `read_volatile` is declared `unsafe`. // (https://doc.rust-lang.org/core/ptr/fn.read_volatile.html, for some food for thought ) // -// ** your answer here ** +// The volatile value might not be guaranteed to be the same between reads. So it is declared unsafe since it might not +// be the same as intended. // // Commit your answers (bare4_2) //