Hi, I am wondering whether the casting here is unsound:
|
pub fn vect_active() -> VectActive { |
|
let icsr = |
|
unsafe { ptr::read_volatile(&(*SCB::PTR).icsr as *const _ as *const u32) } & 0x1FF; |
Based on the definition, the wrapper struct
volatile_register::RW (let me abbreviate it as
vr here) didn't have stable layout, and
rustc would preserve the right to insert padding or reorder the structure.
vr<u32> should be declared as
transparent; otherwise, casting it to
u32 could lead to UB such as uninitialized memory exposure to
ptr::read_volatile.