@@ -44,18 +44,36 @@ LL | intrinsics::ptr_offset_from(self, origin)
4444 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545 | |
4646 | exact_div: 1 cannot be divided by 2 without remainder
47- | inside call to `std::ptr::<impl *const u16>::offset_from` at $DIR/offset_from_ub.rs:33:27
47+ | inside call to `std::ptr::<impl *const u16>::offset_from` at $DIR/offset_from_ub.rs:33:14
4848 |
4949 ::: $DIR/offset_from_ub.rs:28:1
5050 |
51- LL | / pub const NOT_MULTIPLE_OF_SIZE: usize = {
51+ LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
5252LL | |
5353LL | | let data = [5u8, 6, 7];
5454LL | | let base_ptr = data.as_ptr();
55- ... |
56- LL | | offset as usize
55+ LL | | let field_ptr = &data[1] as *const u8 as *const u16;
56+ LL | | unsafe { field_ptr.offset_from(base_ptr as *const u16) }
57+ LL | | };
58+ | |__-
59+
60+ error: any use of this value will cause an error
61+ --> $SRC_DIR/libcore/ptr/mod.rs:LL:COL
62+ |
63+ LL | intrinsics::ptr_offset_from(self, origin)
64+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65+ | |
66+ | invalid use of NULL pointer
67+ | inside call to `std::ptr::<impl *const u8>::offset_from` at $DIR/offset_from_ub.rs:39:14
68+ |
69+ ::: $DIR/offset_from_ub.rs:36:1
70+ |
71+ LL | / pub const OFFSET_FROM_NULL: isize = {
72+ LL | |
73+ LL | | let ptr = 0 as *const u8;
74+ LL | | unsafe { ptr.offset_from(ptr) }
5775LL | | };
5876 | |__-
5977
60- error: aborting due to 3 previous errors
78+ error: aborting due to 4 previous errors
6179
0 commit comments