@@ -328,7 +328,8 @@ where
328
328
} ;
329
329
330
330
let mplace = MemPlace { ptr : ptr. to_pointer ( self ) ?, meta } ;
331
- // When deref'ing a pointer, the *static* alignment given by the type is what matters.
331
+ // `ref_to_mplace` is called on raw pointers even if they don't actually get dereferenced;
332
+ // we hence can't call `size_and_align_of` since that asserts more validity than we want.
332
333
let align = layout. align . abi ;
333
334
Ok ( MPlaceTy { mplace, layout, align } )
334
335
}
@@ -379,11 +380,12 @@ where
379
380
380
381
/// Check if this mplace is dereferenceable and sufficiently aligned.
381
382
pub fn check_mplace ( & self , mplace : MPlaceTy < ' tcx , M :: Provenance > ) -> InterpResult < ' tcx > {
382
- let ( size, align ) = self
383
+ let ( size, _align ) = self
383
384
. size_and_align_of_mplace ( & mplace) ?
384
385
. unwrap_or ( ( mplace. layout . size , mplace. layout . align . abi ) ) ;
385
- assert ! ( mplace. align <= align, "dynamic alignment less strict than static one?" ) ;
386
- let align = if M :: enforce_alignment ( self ) . should_check ( ) { align } else { Align :: ONE } ;
386
+ // Due to packed places, only `mplace.align` matters.
387
+ let align =
388
+ if M :: enforce_alignment ( self ) . should_check ( ) { mplace. align } else { Align :: ONE } ;
387
389
self . check_ptr_access_align ( mplace. ptr , size, align, CheckInAllocMsg :: DerefTest ) ?;
388
390
Ok ( ( ) )
389
391
}
0 commit comments