Add flag for stricter checks on uninit/zeroed
This commit is contained in:
@@ -15,7 +15,7 @@ use rustc_middle::ty::layout::LayoutOf as _;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::abi::{Abi, Align, Primitive, Size};
|
||||
use rustc_target::abi::{Abi, Align, InitKind, Primitive, Size};
|
||||
|
||||
use super::{
|
||||
util::ensure_monomorphic_enough, CheckInAllocMsg, ImmTy, InterpCx, Machine, OpTy, PlaceTy,
|
||||
@@ -408,7 +408,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
)?;
|
||||
}
|
||||
if intrinsic_name == sym::assert_zero_valid
|
||||
&& !layout.might_permit_raw_init(self, /*zero:*/ true)
|
||||
&& !layout.might_permit_raw_init(
|
||||
self,
|
||||
InitKind::Zero,
|
||||
self.tcx.sess.opts.debugging_opts.strict_init_checks,
|
||||
)
|
||||
{
|
||||
M::abort(
|
||||
self,
|
||||
@@ -419,7 +423,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
)?;
|
||||
}
|
||||
if intrinsic_name == sym::assert_uninit_valid
|
||||
&& !layout.might_permit_raw_init(self, /*zero:*/ false)
|
||||
&& !layout.might_permit_raw_init(
|
||||
self,
|
||||
InitKind::Uninit,
|
||||
self.tcx.sess.opts.debugging_opts.strict_init_checks,
|
||||
)
|
||||
{
|
||||
M::abort(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user