From e27f04cd8291b7770f5d9282ef1d7ab267dd7cdb Mon Sep 17 00:00:00 2001
From: Grumme2 <agh@live.se>
Date: Thu, 16 Apr 2020 10:41:06 +0200
Subject: [PATCH] bare4_2

---
 examples/bare4.rs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/examples/bare4.rs b/examples/bare4.rs
index 1a381a5..5186bc9 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)]
@@ -106,6 +106,17 @@ fn main() -> ! {
 //    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
+//        --> examples/bare4.rs:40:5
+//         |
+//      40 |     core::ptr::read_volatile(addr as *const _)
+//         |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+//         |
+//         = note: consult the function's documentation for information on how to avoid undefined behavior
+//      
+//      error: aborting due to previous error
+// 
+//      Reading adresses is not safe so it panics 
 //
 //    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 )
-- 
GitLab