Skip to content

Commit 6797d52

Browse files
committed
make sure we handle all transmute invocations, including diverging ones
1 parent b91bf7a commit 6797d52

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/librustc_mir/interpret/intrinsics.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9696
ret: Option<(PlaceTy<'tcx, M::PointerTag>, mir::BasicBlock)>,
9797
) -> InterpResult<'tcx, bool> {
9898
let substs = instance.substs;
99+
let intrinsic_name = &*self.tcx.item_name(instance.def_id()).as_str();
99100

100-
// We currently do not handle any diverging intrinsics.
101+
// We currently do not handle any intrinsics that are *allowed* to diverge,
102+
// but `transmute` could lack a return place in case of UB.
101103
let (dest, ret) = match ret {
102104
Some(p) => p,
103-
None => return Ok(false)
105+
None => match intrinsic_name {
106+
"transmute" => throw_ub!(Unreachable),
107+
_ => return Ok(false),
108+
}
104109
};
105-
let intrinsic_name = &*self.tcx.item_name(instance.def_id()).as_str();
106110

107111
match intrinsic_name {
108112
"caller_location" => {

0 commit comments

Comments
 (0)