Skip to content

Commit 9a378c3

Browse files
committed
Fix transmute of non-scalar to scalar
Fixes #967
1 parent a78f851 commit 9a378c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/value_and_place.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'tcx> CValue<'tcx> {
123123
scalar_to_clif_type(fx.tcx, element.clone())
124124
.by(u16::try_from(count).unwrap()).unwrap()
125125
}
126-
_ => unreachable!(),
126+
_ => unreachable!("{:?}", layout.ty),
127127
};
128128
ptr.load(fx, clif_ty, MemFlags::new())
129129
}
@@ -458,7 +458,7 @@ impl<'tcx> CPlace<'tcx> {
458458
let dst_layout = self.layout();
459459
let to_ptr = match self.inner {
460460
CPlaceInner::Var(var) => {
461-
let data = from.load_scalar(fx);
461+
let data = CValue(from.0, dst_layout).load_scalar(fx);
462462
let src_ty = fx.bcx.func.dfg.value_type(data);
463463
let dst_ty = fx.clif_type(self.layout().ty).unwrap();
464464
let data = match (src_ty, dst_ty) {
@@ -487,7 +487,7 @@ impl<'tcx> CPlace<'tcx> {
487487
CPlaceInner::Addr(_, Some(_)) => bug!("Can't write value to unsized place {:?}", self),
488488
};
489489

490-
match self.layout().abi {
490+
match from.layout().abi {
491491
// FIXME make Abi::Vector work too
492492
Abi::Scalar(_) => {
493493
let val = from.load_scalar(fx);

0 commit comments

Comments
 (0)