summary refs log tree commit diff
path: root/src/test/ui/consts/offset_from_ub.stderr
blob: 663bfbdade0ce932c660dadb1203daec2d16eee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
error[E0080]: evaluation of constant value failed
  --> $DIR/offset_from_ub.rs:18:27
   |
LL |     let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from cannot compute offset of pointers into different allocations.

error[E0080]: evaluation of constant value failed
  --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
   |
LL |         unsafe { intrinsics::ptr_offset_from(self, origin) }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                  |
   |                  0x2a is not a valid pointer
   |                  inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
   | 
  ::: $DIR/offset_from_ub.rs:24:14
   |
LL |     unsafe { (42 as *const u8).offset_from(&5u8) as usize }
   |              ----------------------------------- inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14

error[E0080]: evaluation of constant value failed
  --> $DIR/offset_from_ub.rs:31:14
   |
LL |     unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) }
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder

error[E0080]: evaluation of constant value failed
  --> $DIR/offset_from_ub.rs:37:14
   |
LL |     unsafe { ptr_offset_from(ptr, ptr) }
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation

error[E0080]: evaluation of constant value failed
  --> $DIR/offset_from_ub.rs:44:14
   |
LL |     unsafe { ptr_offset_from(ptr2, ptr1) }
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0x10 is not a valid pointer

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0080`.