Skip to content

Commit d7a2d9a

Browse files
committed
Miri call ABI check: ensure type size+align stay the same
1 parent 4a99c5f commit d7a2d9a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

compiler/rustc_const_eval/src/interpret/terminator.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
185185
// No question
186186
return true;
187187
}
188-
// Compare layout
188+
if caller_abi.layout.size != callee_abi.layout.size
189+
|| caller_abi.layout.align.abi != callee_abi.layout.align.abi
190+
{
191+
// This cannot go well...
192+
// FIXME: What about unsized types?
193+
return false;
194+
}
195+
// The rest *should* be okay, but we are extra conservative.
189196
match (caller_abi.layout.abi, callee_abi.layout.abi) {
190197
// Different valid ranges are okay (once we enforce validity,
191198
// that will take care to make it UB to leave the range, just

0 commit comments

Comments
 (0)