2021-03-31 04:33:45 -05:00
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:15:1
2021-03-31 04:33:45 -05:00
|
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
2021-03-31 04:33:45 -05:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:19:1
2021-03-31 04:33:45 -05:00
|
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
2021-03-31 04:33:45 -05:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:23:1
2021-03-31 04:33:45 -05:00
|
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
2021-03-31 04:33:45 -05:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:26:1
2021-03-31 04:33:45 -05:00
|
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
2021-03-31 04:33:45 -05:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
2022-09-21 06:05:20 -05:00
error[E0080]: evaluation of constant value failed
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:33:1
2021-03-31 04:33:45 -05:00
|
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
2023-08-02 09:14:36 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
2021-03-31 04:33:45 -05:00
|
2022-08-27 16:46:14 -05:00
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
2021-03-31 04:33:45 -05:00
2022-09-21 06:05:20 -05:00
error[E0080]: evaluation of constant value failed
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:36:39
2021-03-31 04:33:45 -05:00
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
2023-08-02 09:14:36 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
2021-03-31 04:33:45 -05:00
|
2022-08-27 16:46:14 -05:00
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
2021-03-31 04:33:45 -05:00
2023-09-11 16:09:11 -05:00
note: erroneous constant encountered
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:36:38
2022-06-02 19:30:29 -05:00
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
2022-11-15 05:06:20 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2022-06-02 19:30:29 -05:00
2022-09-21 06:05:20 -05:00
error[E0080]: evaluation of constant value failed
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:39:86
2021-03-31 04:33:45 -05:00
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
2023-08-02 09:14:36 -05:00
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
2021-03-31 04:33:45 -05:00
|
2022-08-27 16:46:14 -05:00
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
2022-06-02 19:30:29 -05:00
2023-09-11 16:09:11 -05:00
note: erroneous constant encountered
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:39:85
2022-06-02 19:30:29 -05:00
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
2022-11-15 05:06:20 -06:00
| ^^^^^^^^^^^^^^^^^^^^^
2021-03-31 04:33:45 -05:00
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:42:1
2021-03-31 04:33:45 -05:00
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
2023-02-06 09:00:54 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
2021-03-31 04:33:45 -05:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:45:1
2021-03-31 04:33:45 -05:00
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
2023-02-06 09:00:54 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
2021-03-31 04:33:45 -05:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
2022-08-01 18:05:20 -05:00
error[E0080]: evaluation of constant value failed
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:48:41
2021-03-31 04:33:45 -05:00
|
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
2022-08-01 18:05:20 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
2021-03-31 04:33:45 -05:00
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:52:1
2022-02-22 17:49:12 -06:00
|
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
2022-07-17 15:02:49 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
2022-02-22 17:49:12 -06:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2022-02-22 17:49:12 -06:00
}
2022-08-01 18:05:20 -05:00
error[E0080]: evaluation of constant value failed
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:54:38
2021-03-31 04:33:45 -05:00
|
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
2022-08-01 18:05:20 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
2021-03-31 04:33:45 -05:00
2022-02-22 17:49:12 -06:00
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:57:1
2022-02-22 17:49:12 -06:00
|
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
2022-07-17 15:02:49 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
2022-02-22 17:49:12 -06:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2022-02-22 17:49:12 -06:00
}
error[E0080]: it is undefined behavior to use this value
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:59:1
2022-02-22 17:49:12 -06:00
|
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
2023-11-26 11:21:56 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer
2022-02-22 17:49:12 -06:00
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2022-12-22 09:40:50 -06:00
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2022-02-22 17:49:12 -06:00
}
2023-03-11 17:32:54 -06:00
error[E0080]: evaluation of constant value failed
2022-11-20 02:54:45 -06:00
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
2023-09-26 09:25:05 -05:00
= note: accessing memory based on pointer with alignment 1, but alignment 4 is required
2023-03-11 17:32:54 -06:00
|
2022-11-22 06:06:17 -06:00
note: inside `std::ptr::read::<u32>`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
2023-11-19 18:04:06 -06:00
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
2022-11-20 02:54:45 -06:00
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
2022-11-22 06:06:17 -06:00
note: inside `UNALIGNED_READ`
2023-05-05 07:50:59 -05:00
--> $DIR/ub-ref-ptr.rs:66:5
2022-11-20 02:54:45 -06:00
|
LL | ptr.read();
2022-11-22 06:06:17 -06:00
| ^^^^^^^^^^
2022-11-20 02:54:45 -06:00
error: aborting due to 15 previous errors
2021-03-31 04:33:45 -05:00
For more information about this error, try `rustc --explain E0080`.