rust/tests/ui/consts/const-eval/ub-nonnull.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
4.3 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:14:1
2021-03-31 04:33:45 -05:00
|
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 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.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
2021-06-18 12:31:56 -05:00
error[E0080]: evaluation of constant value failed
--> $DIR/ub-nonnull.rs:20:29
2021-03-31 04:33:45 -05:00
|
2021-06-18 12:31:56 -05:00
LL | let out_of_bounds_ptr = &ptr[255];
| ^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC1 has size 1, so pointer to 255 bytes starting at offset 0 is out-of-bounds
2021-03-31 04:33:45 -05:00
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:24:1
2021-03-31 04:33:45 -05:00
|
LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 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.
= 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
--> $DIR/ub-nonnull.rs:26:1
2021-03-31 04:33:45 -05:00
|
LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 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.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-nonnull.rs:34:36
2021-03-31 04:33:45 -05:00
|
LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
--> $DIR/ub-nonnull.rs:43:1
2021-03-31 04:33:45 -05:00
|
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30
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: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:49:1
2021-03-31 04:33:45 -05:00
|
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
2022-02-13 09:27:59 -06:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30
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: $SIZE, align: $ALIGN) {
HEX_DUMP
2021-03-31 04:33:45 -05:00
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:52:1
|
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: 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: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error: aborting due to 8 previous errors
2021-03-31 04:33:45 -05:00
For more information about this error, try `rustc --explain E0080`.