mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Miri: make size/align_of_val work for dangling raw ptrs
This commit is contained in:
parent
158f8d034b
commit
95aed7ab3b
@ -141,9 +141,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
|
||||
sym::min_align_of_val | sym::size_of_val => {
|
||||
let place = self.deref_operand(args[0])?;
|
||||
// Avoid `deref_operand` -- this is not a deref, the ptr does not have to be
|
||||
// dereferencable!
|
||||
let place = self.ref_to_mplace(self.read_immediate(args[0])?)?;
|
||||
let (size, align) = self
|
||||
.size_and_align_of(place.meta, place.layout)?
|
||||
.size_and_align_of_mplace(place)?
|
||||
.ok_or_else(|| err_unsup_format!("`extern type` does not have known layout"))?;
|
||||
|
||||
let result = match intrinsic_name {
|
||||
|
@ -391,7 +391,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
||||
}
|
||||
// Make sure this is dereferenceable and all.
|
||||
let size_and_align = try_validation!(
|
||||
self.ecx.size_and_align_of(place.meta, place.layout),
|
||||
self.ecx.size_and_align_of_mplace(place),
|
||||
self.path,
|
||||
err_ub!(InvalidMeta(msg)) => { "invalid {} metadata: {}", kind, msg },
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user