interpret: fail more gracefully on uninit unsized locals
This commit is contained in:
parent
8b8110e146
commit
25e9b79060
4 changed files with 20 additions and 1 deletions
|
@ -245,6 +245,12 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
|
|||
impl<'tcx, Prov: Provenance> OpTy<'tcx, Prov> {
|
||||
pub fn len(&self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
|
||||
if self.layout.is_unsized() {
|
||||
if matches!(self.op, Operand::Immediate(Immediate::Uninit)) {
|
||||
// Uninit unsized places shouldn't occur. In the interpreter we have them
|
||||
// temporarily for unsized arguments before their value is put in; in ConstProp they
|
||||
// remain uninit and this code can actually be reached.
|
||||
throw_inval!(UninitUnsizedLocal);
|
||||
}
|
||||
// There are no unsized immediates.
|
||||
self.assert_mem_place().len(cx)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue