]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/const-eval/union-ub.32bit.stderr
Rollup merge of #107146 - compiler-errors:unsizing-params, r=cjgillot
[rust.git] / tests / ui / consts / const-eval / union-ub.32bit.stderr
1 error[E0080]: it is undefined behavior to use this value
2   --> $DIR/union-ub.rs:32:1
3    |
4 LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool};
5    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean
6    |
7    = 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.
8    = note: the raw bytes of the constant (size: 1, align: 1) {
9                2a                                              │ *
10            }
11
12 error[E0080]: evaluation of constant value failed
13   --> $DIR/union-ub.rs:34:36
14    |
15 LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool};
16    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
17
18 error: aborting due to 2 previous errors
19
20 For more information about this error, try `rustc --explain E0080`.