Skip to content

Commit 1057dc9

Browse files
committed
Auto merge of #69509 - RalfJung:debug-assert-write, r=eddyb
debug-assert ptr sanity in ptr::write This is a re-submission of the parts that we removed from #69208 due to ["interesting" test failures](#69208 (comment)). Fixes #53871 r? @Mark-Simulacrum @eddyb
2 parents 2835ca6 + c95f08a commit 1057dc9

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/libcore/ptr/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,7 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T {
810810
#[inline]
811811
#[stable(feature = "rust1", since = "1.0.0")]
812812
pub unsafe fn write<T>(dst: *mut T, src: T) {
813-
// FIXME: the debug assertion here causes codegen test failures on some architectures.
814-
// See <https://github.com/rust-lang/rust/pull/69208#issuecomment-591326757>.
815-
// debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer");
813+
debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer");
816814
intrinsics::move_val_init(&mut *dst, src)
817815
}
818816

src/test/codegen/repeat-trusted-len.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@
55

66
use std::iter;
77

8-
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
9-
#[no_mangle]
10-
pub fn helper(_: usize) {
11-
}
12-
138
// CHECK-LABEL: @repeat_take_collect
149
#[no_mangle]
1510
pub fn repeat_take_collect() -> Vec<u8> {
16-
// CHECK: call void @llvm.memset.p0i8.[[USIZE]](i8* {{(nonnull )?}}align 1{{.*}} %{{[0-9]+}}, i8 42, [[USIZE]] 100000, i1 false)
11+
// CHECK: call void @llvm.memset.p0i8.i{{[0-9]+}}(i8* {{(nonnull )?}}align 1{{.*}} %{{[0-9]+}}, i8 42, i{{[0-9]+}} 100000, i1 false)
1712
iter::repeat(42).take(100000).collect()
1813
}

src/test/ui/issues/issue-40883.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ pub fn supersize_me(out: &mut Vec<Big>) {
7171

7272
#[inline(never)]
7373
fn verify_stack_usage(before_ptr: *mut Vec<Big>) {
74-
// to check stack usage, create locals before and after
74+
// To check stack usage, create locals before and after
7575
// and check the difference in addresses between them.
7676
let mut stack_var: Vec<Big> = vec![];
7777
test::black_box(&mut stack_var);
7878
let stack_usage = isize::abs(
7979
(&mut stack_var as *mut _ as isize) -
8080
(before_ptr as isize)) as usize;
81-
// give space for 2 copies of `Big` + 128 "misc" bytes.
82-
if stack_usage > mem::size_of::<Big>() * 2 + 128 {
81+
// Give space for 2 copies of `Big` + 272 "misc" bytes
82+
// (value observed on x86_64-pc-windows-gnu).
83+
if stack_usage > mem::size_of::<Big>() * 2 + 272 {
8384
panic!("used {} bytes of stack, but `struct Big` is only {} bytes",
8485
stack_usage, mem::size_of::<Big>());
8586
}

0 commit comments

Comments
 (0)