A MIR transform that checks pointers are aligned
This commit is contained in:
parent
e216300876
commit
8ccf53332e
34 changed files with 360 additions and 20 deletions
|
|
@ -159,6 +159,20 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
|
|||
panic!("index out of bounds: the len is {len} but the index is {index}")
|
||||
}
|
||||
|
||||
#[cold]
|
||||
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
|
||||
#[track_caller]
|
||||
#[cfg_attr(not(bootstrap), lang = "panic_misaligned_pointer_dereference")] // needed by codegen for panic on misaligned pointer deref
|
||||
fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! {
|
||||
if cfg!(feature = "panic_immediate_abort") {
|
||||
super::intrinsics::abort()
|
||||
}
|
||||
|
||||
panic!(
|
||||
"misaligned pointer dereference: address must be a multiple of {required:#x} but is {found:#x}"
|
||||
)
|
||||
}
|
||||
|
||||
/// Panic because we cannot unwind out of a function.
|
||||
///
|
||||
/// This function is called directly by the codegen backend, and must not have
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue