rust/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr

76 lines
4.5 KiB
Plaintext
Raw Normal View History

2021-03-31 04:33:45 -05:00
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:12:1
|
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 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: 4, align: 4) {
00 00 00 00 │ ....
}
2021-06-18 12:31:56 -05:00
error[E0080]: evaluation of constant value failed
2021-03-31 04:33:45 -05:00
--> $DIR/ub-nonnull.rs:19:30
|
2021-06-18 12:31:56 -05:00
LL | let out_of_bounds_ptr = &ptr[255];
| ^^^^^^^^ dereferencing pointer failed: pointer must be in-bounds for 256 bytes at offset 0, but alloc11 has size 1
2021-03-31 04:33:45 -05:00
error[E0080]: it is undefined behavior to use this value
2021-06-18 12:31:56 -05:00
--> $DIR/ub-nonnull.rs:23:1
2021-03-31 04:33:45 -05:00
|
LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 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: 1, align: 1) {
00 │ .
}
error[E0080]: it is undefined behavior to use this value
2021-06-18 12:31:56 -05:00
--> $DIR/ub-nonnull.rs:25:1
2021-03-31 04:33:45 -05:00
|
LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 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: 4, align: 4) {
00 00 00 00 │ ....
}
error[E0080]: it is undefined behavior to use this value
2021-06-18 12:31:56 -05:00
--> $DIR/ub-nonnull.rs:33:1
2021-03-31 04:33:45 -05:00
|
LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init };
2021-06-13 16:16:00 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
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.
= note: the raw bytes of the constant (size: 1, align: 1) {
__ │ ░
}
error[E0080]: it is undefined behavior to use this value
2021-06-18 12:31:56 -05:00
--> $DIR/ub-nonnull.rs:41:1
2021-03-31 04:33:45 -05:00
|
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30
|
= 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: 4, align: 4) {
2a 00 00 00 │ *...
}
error[E0080]: it is undefined behavior to use this value
2021-06-18 12:31:56 -05:00
--> $DIR/ub-nonnull.rs:47:1
2021-03-31 04:33:45 -05:00
|
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30
|
= 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: 4, align: 4) {
14 00 00 00 │ ....
}
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0080`.