mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-30 00:23:41 +00:00
cfg out checks in add and sub but not offset
...because the checks in offset found bugs in a crater run.
This commit is contained in:
parent
6d246e47fb
commit
9d5c961fa4
@ -887,6 +887,7 @@ impl<T: ?Sized> *const T {
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
#[cfg(debug_assertions)]
|
||||
#[inline]
|
||||
const fn runtime_add_nowrap(this: *const (), count: usize, size: usize) -> bool {
|
||||
#[inline]
|
||||
@ -905,6 +906,7 @@ impl<T: ?Sized> *const T {
|
||||
intrinsics::const_eval_select((this, count, size), comptime, runtime)
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)] // Expensive, and doesn't catch much in the wild.
|
||||
ub_checks::assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
"ptr::add requires that the address calculation does not overflow",
|
||||
@ -993,6 +995,7 @@ impl<T: ?Sized> *const T {
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
#[cfg(debug_assertions)]
|
||||
#[inline]
|
||||
const fn runtime_sub_nowrap(this: *const (), count: usize, size: usize) -> bool {
|
||||
#[inline]
|
||||
@ -1010,6 +1013,7 @@ impl<T: ?Sized> *const T {
|
||||
intrinsics::const_eval_select((this, count, size), comptime, runtime)
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)] // Expensive, and doesn't catch much in the wild.
|
||||
ub_checks::assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
"ptr::sub requires that the address calculation does not overflow",
|
||||
|
@ -971,6 +971,7 @@ impl<T: ?Sized> *mut T {
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
#[cfg(debug_assertions)]
|
||||
#[inline]
|
||||
const fn runtime_add_nowrap(this: *const (), count: usize, size: usize) -> bool {
|
||||
#[inline]
|
||||
@ -989,6 +990,7 @@ impl<T: ?Sized> *mut T {
|
||||
intrinsics::const_eval_select((this, count, size), comptime, runtime)
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)] // Expensive, and doesn't catch much in the wild.
|
||||
ub_checks::assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
"ptr::add requires that the address calculation does not overflow",
|
||||
@ -1077,6 +1079,7 @@ impl<T: ?Sized> *mut T {
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
#[cfg(debug_assertions)]
|
||||
#[inline]
|
||||
const fn runtime_sub_nowrap(this: *const (), count: usize, size: usize) -> bool {
|
||||
#[inline]
|
||||
@ -1094,6 +1097,7 @@ impl<T: ?Sized> *mut T {
|
||||
intrinsics::const_eval_select((this, count, size), comptime, runtime)
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)] // Expensive, and doesn't catch much in the wild.
|
||||
ub_checks::assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
"ptr::sub requires that the address calculation does not overflow",
|
||||
|
Loading…
Reference in New Issue
Block a user