|
| 1 | +error[E0080]: evaluation of constant value failed |
| 2 | + --> $DIR/const-compare-bytes-ub.rs:10:9 |
| 3 | + | |
| 4 | +LL | compare_bytes(0 as *const u8, 2 as *const u8, 0) |
| 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance) |
| 6 | + |
| 7 | +error[E0080]: evaluation of constant value failed |
| 8 | + --> $DIR/const-compare-bytes-ub.rs:14:9 |
| 9 | + | |
| 10 | +LL | compare_bytes(1 as *const u8, 0 as *const u8, 0) |
| 11 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance) |
| 12 | + |
| 13 | +error[E0080]: evaluation of constant value failed |
| 14 | + --> $DIR/const-compare-bytes-ub.rs:18:9 |
| 15 | + | |
| 16 | +LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) |
| 17 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0x1[noalloc] is a dangling pointer (it has no provenance) |
| 18 | + |
| 19 | +error[E0080]: evaluation of constant value failed |
| 20 | + --> $DIR/const-compare-bytes-ub.rs:22:9 |
| 21 | + | |
| 22 | +LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) |
| 23 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc6 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds |
| 24 | + |
| 25 | +error[E0080]: evaluation of constant value failed |
| 26 | + --> $DIR/const-compare-bytes-ub.rs:26:9 |
| 27 | + | |
| 28 | +LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) |
| 29 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc13 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds |
| 30 | + |
| 31 | +error[E0080]: evaluation of constant value failed |
| 32 | + --> $DIR/const-compare-bytes-ub.rs:30:9 |
| 33 | + | |
| 34 | +LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) |
| 35 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc17[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory |
| 36 | + |
| 37 | +error[E0080]: evaluation of constant value failed |
| 38 | + --> $DIR/const-compare-bytes-ub.rs:34:9 |
| 39 | + | |
| 40 | +LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) |
| 41 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc25[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory |
| 42 | + |
| 43 | +error[E0080]: evaluation of constant value failed |
| 44 | + --> $DIR/const-compare-bytes-ub.rs:38:9 |
| 45 | + | |
| 46 | +LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::<usize>()) |
| 47 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer |
| 48 | + | |
| 49 | + = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 50 | + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 51 | + |
| 52 | +error: aborting due to 8 previous errors |
| 53 | + |
| 54 | +For more information about this error, try `rustc --explain E0080`. |
0 commit comments