Skip to content

Commit

Permalink
Auto merge of #129498 - saethlin:ptr-read-write-precondition, r=<try>
Browse files Browse the repository at this point in the history
Try enabling precondition checks on ptr::{read,write}

The overhead here is probably too much, but let's have the measurement anyway.

This will fail at least one codegen test.

r? `@ghost`
  • Loading branch information
bors committed Aug 24, 2024
2 parents 4074d49 + 0a65e30 commit aadda4d
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,6 @@ pub const unsafe fn read<T>(src: *const T) -> T {

// SAFETY: the caller must guarantee that `src` is valid for reads.
unsafe {
#[cfg(debug_assertions)] // Too expensive to always enable (for now?)
ub_checks::assert_unsafe_precondition!(
check_language_ub,
"ptr::read requires that the pointer argument is aligned and non-null",
Expand Down Expand Up @@ -1596,7 +1595,6 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
// `dst` cannot overlap `src` because the caller has mutable access
// to `dst` while `src` is owned by this function.
unsafe {
#[cfg(debug_assertions)] // Too expensive to always enable (for now?)
ub_checks::assert_unsafe_precondition!(
check_language_ub,
"ptr::write requires that the pointer argument is aligned and non-null",
Expand Down

0 comments on commit aadda4d

Please sign in to comment.