|
| 1 | +warning: transmuting an integer to a pointer creates a pointer without provenance |
| 2 | + --> $DIR/int_to_ptr.rs:10:25 |
| 3 | + | |
| 4 | +LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) }; |
| 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 6 | + | |
| 7 | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior |
| 8 | + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance |
| 9 | + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` |
| 10 | + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> |
| 11 | + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> |
| 12 | + = note: `#[warn(integer_to_ptr_transmutes)]` on by default |
| 13 | +help: use `as` cast instead to use a previously exposed provenance |
| 14 | + | |
| 15 | +LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) }; |
| 16 | +LL + let _ptr = unsafe { a as *const u8 }; |
| 17 | + | |
| 18 | + |
| 19 | +warning: transmuting an integer to a pointer creates a pointer without provenance |
| 20 | + --> $DIR/int_to_ptr.rs:12:25 |
| 21 | + | |
| 22 | +LL | let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) }; |
| 23 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 24 | + | |
| 25 | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior |
| 26 | + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance |
| 27 | + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` |
| 28 | + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> |
| 29 | + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> |
| 30 | +help: use `as` cast instead to use a previously exposed provenance |
| 31 | + | |
| 32 | +LL - let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) }; |
| 33 | +LL + let _ptr = unsafe { &*(a as *const u8) }; |
| 34 | + | |
| 35 | + |
| 36 | +warning: transmuting an integer to a pointer creates a pointer without provenance |
| 37 | + --> $DIR/int_to_ptr.rs:14:25 |
| 38 | + | |
| 39 | +LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) }; |
| 40 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 41 | + | |
| 42 | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior |
| 43 | + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance |
| 44 | + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` |
| 45 | + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> |
| 46 | + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> |
| 47 | +help: use `as` cast instead to use a previously exposed provenance |
| 48 | + | |
| 49 | +LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) }; |
| 50 | +LL + let _ptr = unsafe { 42usize as *const u8 }; |
| 51 | + | |
| 52 | + |
| 53 | +warning: transmuting an integer to a pointer creates a pointer without provenance |
| 54 | + --> $DIR/int_to_ptr.rs:16:25 |
| 55 | + | |
| 56 | +LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) }; |
| 57 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 58 | + | |
| 59 | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior |
| 60 | + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance |
| 61 | + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` |
| 62 | + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> |
| 63 | + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> |
| 64 | +help: use `as` cast instead to use a previously exposed provenance |
| 65 | + | |
| 66 | +LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) }; |
| 67 | +LL + let _ptr = unsafe { (a + a) as *const u8 }; |
| 68 | + | |
| 69 | + |
| 70 | +warning: transmuting an integer to a pointer creates a pointer without provenance |
| 71 | + --> $DIR/int_to_ptr.rs:21:25 |
| 72 | + | |
| 73 | +LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) }; |
| 74 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 75 | + | |
| 76 | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior |
| 77 | + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance |
| 78 | + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` |
| 79 | + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> |
| 80 | + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> |
| 81 | +help: use `as` cast instead to use a previously exposed provenance |
| 82 | + | |
| 83 | +LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) }; |
| 84 | +LL + let _ptr = unsafe { a as *const u8 }; |
| 85 | + | |
| 86 | + |
| 87 | +warning: transmuting an integer to a pointer creates a pointer without provenance |
| 88 | + --> $DIR/int_to_ptr.rs:23:25 |
| 89 | + | |
| 90 | +LL | let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) }; |
| 91 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 92 | + | |
| 93 | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior |
| 94 | + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance |
| 95 | + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` |
| 96 | + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> |
| 97 | + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> |
| 98 | +help: use `as` cast instead to use a previously exposed provenance |
| 99 | + | |
| 100 | +LL - let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) }; |
| 101 | +LL + let _ptr = unsafe { &*(a as *const u8) }; |
| 102 | + | |
| 103 | + |
| 104 | +warning: transmuting an integer to a pointer creates a pointer without provenance |
| 105 | + --> $DIR/int_to_ptr.rs:25:25 |
| 106 | + | |
| 107 | +LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) }; |
| 108 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 109 | + | |
| 110 | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior |
| 111 | + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance |
| 112 | + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` |
| 113 | + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> |
| 114 | + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> |
| 115 | +help: use `as` cast instead to use a previously exposed provenance |
| 116 | + | |
| 117 | +LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) }; |
| 118 | +LL + let _ptr = unsafe { 42usize as *const u8 }; |
| 119 | + | |
| 120 | + |
| 121 | +warning: transmuting an integer to a pointer creates a pointer without provenance |
| 122 | + --> $DIR/int_to_ptr.rs:27:25 |
| 123 | + | |
| 124 | +LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) }; |
| 125 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 126 | + | |
| 127 | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior |
| 128 | + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance |
| 129 | + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` |
| 130 | + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> |
| 131 | + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> |
| 132 | +help: use `as` cast instead to use a previously exposed provenance |
| 133 | + | |
| 134 | +LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) }; |
| 135 | +LL + let _ptr = unsafe { (a + a) as *const u8 }; |
| 136 | + | |
| 137 | + |
| 138 | +warning: 8 warnings emitted |
| 139 | + |
0 commit comments