]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/offset_from_ub.stderr
New upstream version 1.42.0+dfsg1
[rustc.git] / src / test / ui / consts / offset_from_ub.stderr
CommitLineData
e74abb32 1error: any use of this value will cause an error
dfeec247 2 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
e74abb32
XL
3 |
4LL | intrinsics::ptr_offset_from(self, origin)
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 | |
7 | ptr_offset_from cannot compute offset of pointers into different allocations.
dfeec247 8 | inside call to `std::ptr::const_ptr::<impl *const Struct>::offset_from` at $DIR/offset_from_ub.rs:22:27
e74abb32 9 |
dfeec247 10 ::: $DIR/offset_from_ub.rs:16:1
e74abb32
XL
11 |
12LL | / pub const DIFFERENT_ALLOC: usize = {
13LL | |
14LL | | let uninit = std::mem::MaybeUninit::<Struct>::uninit();
15LL | | let base_ptr: *const Struct = &uninit as *const _ as *const Struct;
16... |
17LL | | offset as usize
18LL | | };
19 | |__-
20 |
21 = note: `#[deny(const_err)]` on by default
22
23error: any use of this value will cause an error
dfeec247 24 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
e74abb32
XL
25 |
26LL | intrinsics::ptr_offset_from(self, origin)
27 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28 | |
29 | a memory access tried to interpret some bytes as a pointer
dfeec247 30 | inside call to `std::ptr::const_ptr::<impl *const u8>::offset_from` at $DIR/offset_from_ub.rs:28:14
e74abb32 31 |
dfeec247 32 ::: $DIR/offset_from_ub.rs:26:1
e74abb32
XL
33 |
34LL | / pub const NOT_PTR: usize = {
35LL | |
36LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
37LL | | };
38 | |__-
39
40error: any use of this value will cause an error
dfeec247 41 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
e74abb32
XL
42 |
43LL | intrinsics::ptr_offset_from(self, origin)
44 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45 | |
46 | exact_div: 1 cannot be divided by 2 without remainder
dfeec247 47 | inside call to `std::ptr::const_ptr::<impl *const u16>::offset_from` at $DIR/offset_from_ub.rs:36:14
e74abb32 48 |
dfeec247 49 ::: $DIR/offset_from_ub.rs:31:1
e74abb32 50 |
60c5eb7d 51LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
e74abb32
XL
52LL | |
53LL | | let data = [5u8, 6, 7];
54LL | | let base_ptr = data.as_ptr();
60c5eb7d
XL
55LL | | let field_ptr = &data[1] as *const u8 as *const u16;
56LL | | unsafe { field_ptr.offset_from(base_ptr as *const u16) }
57LL | | };
58 | |__-
59
60error: any use of this value will cause an error
dfeec247 61 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
60c5eb7d
XL
62 |
63LL | intrinsics::ptr_offset_from(self, origin)
64 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65 | |
66 | invalid use of NULL pointer
dfeec247 67 | inside call to `std::ptr::const_ptr::<impl *const u8>::offset_from` at $DIR/offset_from_ub.rs:42:14
60c5eb7d 68 |
dfeec247 69 ::: $DIR/offset_from_ub.rs:39:1
60c5eb7d
XL
70 |
71LL | / pub const OFFSET_FROM_NULL: isize = {
72LL | |
73LL | | let ptr = 0 as *const u8;
74LL | | unsafe { ptr.offset_from(ptr) }
75LL | | };
76 | |__-
77
78error: any use of this value will cause an error
dfeec247 79 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
60c5eb7d
XL
80 |
81LL | intrinsics::ptr_offset_from(self, origin)
82 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
83 | |
84 | a memory access tried to interpret some bytes as a pointer
dfeec247 85 | inside call to `std::ptr::const_ptr::<impl *const u8>::offset_from` at $DIR/offset_from_ub.rs:49:14
60c5eb7d 86 |
dfeec247 87 ::: $DIR/offset_from_ub.rs:45:1
60c5eb7d
XL
88 |
89LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
90LL | |
91LL | | let ptr1 = 8 as *const u8;
92LL | | let ptr2 = 16 as *const u8;
93LL | | unsafe { ptr2.offset_from(ptr1) }
e74abb32
XL
94LL | | };
95 | |__-
96
60c5eb7d 97error: aborting due to 5 previous errors
e74abb32 98