Skip to content
Snippets Groups Projects
Commit e27f04cd authored by Anton Grahn's avatar Anton Grahn
Browse files

bare4_2

parent 0f74ecf5
Branches
No related tags found
No related merge requests found
......@@ -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 )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment