on a signed deref check, mention the right pointer in the error
This commit is contained in:
parent
70591dc15d
commit
de78cb56b2
34 changed files with 192 additions and 141 deletions
|
@ -334,14 +334,15 @@ pub enum UndefinedBehaviorInfo<'tcx> {
|
|||
alloc_size: Size,
|
||||
ptr_offset: i64,
|
||||
/// The size of the memory range that was expected to be in-bounds.
|
||||
inbounds_size: Size,
|
||||
inbounds_size: i64,
|
||||
msg: CheckInAllocMsg,
|
||||
},
|
||||
/// Using an integer as a pointer in the wrong way.
|
||||
DanglingIntPointer {
|
||||
addr: u64,
|
||||
/// The size of the memory range that was expected to be in-bounds (or 0 if we don't know).
|
||||
inbounds_size: Size,
|
||||
/// The size of the memory range that was expected to be in-bounds (or 0 if we need an
|
||||
/// allocation but not any actual memory there, e.g. for function pointers).
|
||||
inbounds_size: i64,
|
||||
msg: CheckInAllocMsg,
|
||||
},
|
||||
/// Used a pointer with bad alignment.
|
||||
|
|
|
@ -181,12 +181,9 @@ impl Provenance for CtfeProvenance {
|
|||
fn fmt(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// Print AllocId.
|
||||
fmt::Debug::fmt(&ptr.provenance.alloc_id(), f)?; // propagates `alternate` flag
|
||||
// Print offset only if it is non-zero. Print it signed.
|
||||
let signed_offset = ptr.offset.bytes() as i64;
|
||||
if signed_offset > 0 {
|
||||
write!(f, "+{:#x}", signed_offset)?;
|
||||
} else if signed_offset < 0 {
|
||||
write!(f, "-{:#x}", signed_offset.unsigned_abs())?;
|
||||
// Print offset only if it is non-zero.
|
||||
if ptr.offset.bytes() > 0 {
|
||||
write!(f, "+{:#x}", ptr.offset.bytes())?;
|
||||
}
|
||||
// Print immutable status.
|
||||
if ptr.provenance.immutable() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue