Skip to content
Snippets Groups Projects
Commit 46dfaa68 authored by August Svensson's avatar August Svensson
Browse files

bare4_2

parent 7bcac141
No related branches found
No related tags found
No related merge requests found
...@@ -36,8 +36,8 @@ use address::*; ...@@ -36,8 +36,8 @@ use address::*;
#[inline(always)] #[inline(always)]
fn read_u32(addr: u32) -> u32 { fn read_u32(addr: u32) -> u32 {
unsafe { core::ptr::read_volatile(addr as *const _) } // unsafe { core::ptr::read_volatile(addr as *const _) }
//core::ptr::read_volatile(addr as *const _) core::ptr::read_volatile(addr as *const _)
} }
#[inline(always)] #[inline(always)]
...@@ -101,12 +101,14 @@ fn main() -> ! { ...@@ -101,12 +101,14 @@ fn main() -> ! {
// //
// What was the error message and explain why. // What was the error message and explain why.
// //
// ** your answer here ** // ** Compiler error E0133: "call to unsafe function is unsafe ..."
// Because read_volatile is defined as unsafe. **
// //
// Digging a bit deeper, why do you think `read_volatile` is declared `unsafe`. // 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 ) // (https://doc.rust-lang.org/core/ptr/fn.read_volatile.html, for some food for thought )
// //
// ** your answer here ** // ** The section on safety reads that the behaviour is undefined if the parameter is not valid.
// The passed parameter must not be unaligned nor out of bounds. Undefined behaviour is unsafe! **
// //
// Commit your answers (bare4_2) // Commit your answers (bare4_2)
// //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment