Skip to content

Commit e8972eb

Browse files
committed
Add a debug check for ordering, and check for isize overflow in CTFE
1 parent 3ad95f6 commit e8972eb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/ptr/const_ptr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,10 @@ impl<T: ?Sized> *const T {
678678
where
679679
T: Sized,
680680
{
681+
// SAFETY: The comparison has no side-effects, and the intrinsic
682+
// does this check internally in the CTFE implementation.
683+
unsafe { assert_unsafe_precondition!(self >= origin) };
684+
681685
let pointee_size = mem::size_of::<T>();
682686
assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
683687
// SAFETY: the caller must uphold the safety contract for `ptr_offset_from_unsigned`.

0 commit comments

Comments
 (0)