]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/union-ice.rs
Merge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyup
[rust.git] / src / test / ui / consts / const-eval / union-ice.rs
1 // only-x86_64
2
3 type Field1 = i32;
4 type Field3 = i64;
5
6 #[repr(C)]
7 union DummyUnion {
8     field1: Field1,
9     field3: Field3,
10 }
11
12 const UNION: DummyUnion = DummyUnion { field1: 1065353216 };
13
14 const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR it is undefined behavior to use this value
15
16 const FIELD_PATH: Struct = Struct { //~ ERROR it is undefined behavior to use this value
17     a: 42,
18     b: unsafe { UNION.field3 },
19 };
20
21 struct Struct {
22     a: u8,
23     b: Field3,
24 }
25
26 const FIELD_PATH2: Struct2 = Struct2 { //~ ERROR it is undefined behavior to use this value
27     b: [
28         21,
29         unsafe { UNION.field3 },
30         23,
31         24,
32     ],
33     a: 42,
34 };
35
36 struct Struct2 {
37     b: [Field3; 4],
38     a: u8,
39 }
40
41 fn main() {
42 }