@@ -44,18 +44,36 @@ LL | intrinsics::ptr_offset_from(self, origin)
44
44
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45
45
| |
46
46
| 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
48
48
|
49
49
::: $DIR/offset_from_ub.rs:28:1
50
50
|
51
- LL | / pub const NOT_MULTIPLE_OF_SIZE: usize = {
51
+ LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
52
52
LL | |
53
53
LL | | let data = [5u8, 6, 7];
54
54
LL | | 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) }
57
75
LL | | };
58
76
| |__-
59
77
60
- error: aborting due to 3 previous errors
78
+ error: aborting due to 4 previous errors
61
79
0 commit comments