mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
169 lines
8.5 KiB
Plaintext
169 lines
8.5 KiB
Plaintext
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:15:1
|
|
|
|
|
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:19:1
|
|
|
|
|
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:23:1
|
|
|
|
|
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
|
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:26:1
|
|
|
|
|
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: evaluation of constant value failed
|
|
--> $DIR/ub-ref-ptr.rs:33:1
|
|
|
|
|
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
|
|
|
|
|
= 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
|
|
|
|
error[E0080]: evaluation of constant value failed
|
|
--> $DIR/ub-ref-ptr.rs:36:39
|
|
|
|
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
|
|
|
|
|
= 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
|
|
|
|
note: erroneous constant encountered
|
|
--> $DIR/ub-ref-ptr.rs:36:38
|
|
|
|
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error[E0080]: evaluation of constant value failed
|
|
--> $DIR/ub-ref-ptr.rs:39:86
|
|
|
|
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
|
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
|
|
|
|
|
= 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
|
|
|
|
note: erroneous constant encountered
|
|
--> $DIR/ub-ref-ptr.rs:39:85
|
|
|
|
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:42:1
|
|
|
|
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:45:1
|
|
|
|
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: evaluation of constant value failed
|
|
--> $DIR/ub-ref-ptr.rs:48:41
|
|
|
|
|
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
|
|
|
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:52:1
|
|
|
|
|
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: evaluation of constant value failed
|
|
--> $DIR/ub-ref-ptr.rs:54:38
|
|
|
|
|
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
|
|
|
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:57:1
|
|
|
|
|
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: it is undefined behavior to use this value
|
|
--> $DIR/ub-ref-ptr.rs:59:1
|
|
|
|
|
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer
|
|
|
|
|
= 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.
|
|
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
|
HEX_DUMP
|
|
}
|
|
|
|
error[E0080]: evaluation of constant value failed
|
|
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
|
|
|
|
= note: accessing memory based on pointer with alignment 1, but alignment 4 is required
|
|
|
|
|
note: inside `std::ptr::read::<u32>`
|
|
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
|
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
|
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
|
note: inside `UNALIGNED_READ`
|
|
--> $DIR/ub-ref-ptr.rs:66:5
|
|
|
|
|
LL | ptr.read();
|
|
| ^^^^^^^^^^
|
|
|
|
error: aborting due to 15 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0080`.
|