Do not transmute immediates to non-immediates.
This commit is contained in:
parent
db9bd9bd8c
commit
9389373127
1 changed files with 10 additions and 0 deletions
|
@ -443,6 +443,16 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||
CastKind::Transmute => {
|
||||
let value = self.evaluated[value].as_ref()?;
|
||||
let to = self.ecx.layout_of(to).ok()?;
|
||||
// `offset` for immediates only supports scalar/scalar-pair ABIs,
|
||||
// so bail out if the target is not one.
|
||||
if value.as_mplace_or_imm().is_right() {
|
||||
match to.abi {
|
||||
Abi::Scalar(..) | Abi::ScalarPair(..) => {}
|
||||
_ if to.is_zst() => {}
|
||||
Abi::Aggregate { .. } if to.fields.count() == 0 => {}
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
value.offset(Size::ZERO, to, &self.ecx).ok()?
|
||||
}
|
||||
_ => return None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue