rust/src/test/ui/consts/const-eval/union-ice.rs

44 lines
760 B
Rust
Raw Normal View History

// stderr-per-bitwidth
2018-06-04 11:32:06 -05:00
#![feature(const_fn)]
type Field1 = i32;
type Field3 = i64;
#[repr(C)]
2018-06-04 11:32:06 -05:00
union DummyUnion {
field1: Field1,
field3: Field3,
}
const UNION: DummyUnion = DummyUnion { field1: 1065353216 };
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR it is undefined behavior to use this value
2018-06-04 11:32:06 -05:00
2018-10-01 05:52:47 -05:00
const FIELD_PATH: Struct = Struct { //~ ERROR it is undefined behavior to use this value
2018-06-04 11:32:06 -05:00
a: 42,
b: unsafe { UNION.field3 },
};
struct Struct {
a: u8,
b: Field3,
}
const FIELD_PATH2: Struct2 = Struct2 { //~ ERROR it is undefined behavior to use this value
2018-06-04 11:32:06 -05:00
b: [
21,
unsafe { UNION.field3 },
23,
24,
],
a: 42,
};
struct Struct2 {
b: [Field3; 4],
a: u8,
}
fn main() {
}