From 3979185e0e23b7eecd015974e38c86221716bef8 Mon Sep 17 00:00:00 2001 From: Josef Utbult <josutb-7@student.ltu.se> Date: Fri, 5 Mar 2021 15:14:53 +0100 Subject: [PATCH] bare4_2 --- examples/rtic_bare4.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/rtic_bare4.rs b/examples/rtic_bare4.rs index f9f2fe7..28e5e2e 100644 --- a/examples/rtic_bare4.rs +++ b/examples/rtic_bare4.rs @@ -36,8 +36,8 @@ use address::*; // Here we have low level access to a bit in a register #[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 _) } // Here we have low level access to a bit in a register @@ -102,12 +102,13 @@ const APP: () = { // // What was the error message and explain why. // -// ** your answer here ** +// error[E0133]: call to unsafe function is unsafe and requires unsafe function or block +// I guess this is because you cant make sure that the adress is valid. // // 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 ** +// Because you can get undefined behaviour // // Commit your answers (bare4_2) // -- GitLab