From 44aed7a6084a42f95b33675a41d7bbd5499b9b38 Mon Sep 17 00:00:00 2001 From: Ridgep <ridpet-5@student.ltu.se> Date: Fri, 8 Mar 2019 14:06:48 +0100 Subject: [PATCH] bare4_2 --- examples/bare4.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/bare4.rs b/examples/bare4.rs index e0782ae..ea70453 100644 --- a/examples/bare4.rs +++ b/examples/bare4.rs @@ -101,12 +101,15 @@ fn main() -> ! { // // What was the error message and explain why. // -// ** your answer here ** +// Error message recieved "call to unsafe function". This is because the function being called +// is volatile, and has to be run in a unsafe function or block. // // 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 ** +// read_volatile is a declared volatile operation, and thus are guarenteed to not be the same +// when read at different occassions. Declaring it as unsafe disables the rust memory guarentee, which +// allows the volatile function to read the memory. // // Commit your answers (bare4_2) // -- GitLab