Change:
code from rustc this causes a new panic when executed via miri:
Ah, there was a reason why we disabled alignment checks in CTFE... This can probably be reproduced without Miri by passing -Zextra-const-ub-checks to rustc.
Yeah this just need "cargo miri run", no additional flags required. Edit: oops, misread :sweat_smile:
Right, this does also reproduce with . Do you want to move the issue?
Yeah let's move this to the rustc repo.

Discussion:
} /// The `InterpCx` is only meant to be used to do field and index projections into constants for <del> /// `simd_shuffle` and const patterns in match arms. </del> <ins> /// `simd_shuffle` and const patterns in match arms. It never performs alignment checks. </ins> /// /// The function containing the `match` that is currently being analyzed may have generic bounds /// that inform us about the generic bounds of the constant. E.g., using an associated constant

tcx, root_span, param_env, <del> CompileTimeInterpreter::new(tcx.const_eval_limit(), can_access_statics), </del> <ins> CompileTimeInterpreter::new( tcx.const_eval_limit(), can_access_statics, /*check_alignment:*/ false, ), </ins> ) }

let cid = key.value; let def_id = cid.instance.def.def_id(); let is_static = tcx.is_static(def_id); <del> let ecx = mk_eval_cx(tcx, tcx.def_span(key.value.instance.def_id()), key.param_env, is_static); </del> <ins> // This is just accessing an already computed constant, so no need to check alginment here. let ecx = mk_eval_cx( tcx, tcx.def_span(key.value.instance.def_id()), key.param_env, /*can_access_statics:*/ is_static, ); </ins> let mplace = ecx.raw_const_to_mplace(constant).expect( "can only fail if layout computation failed, 

key.param_env, // Statics (and promoteds inside statics) may access other statics, because unlike consts // they do not have to behave "as if" they were evaluated at runtime. <del> CompileTimeInterpreter::new(tcx.const_eval_limit(), /*can_access_statics:*/ is_static), </del> <ins> CompileTimeInterpreter::new( tcx.const_eval_limit(), /*can_access_statics:*/ is_static, /*check_alignment:*/ tcx.sess.opts.unstable_opts.extra_const_ub_checks, ), </ins> ); let res = ecx.load_mir(cid.instance.def, cid.promoted);

/// * Pointers to allocations inside of statics can never leak outside, to a non-static global. /// This boolean here controls the second part. pub(super) can_access_statics: bool, <ins> /// Whether to check alignment during evaluation. check_alignment: bool, </ins> } impl<'mir, 'tcx> CompileTimeInterpreter<'mir, 'tcx> { <del> pub(crate) fn new(const_eval_limit: Limit, can_access_statics: bool) -> Self { </del> <ins> pub(crate) fn new( const_eval_limit: Limit, can_access_statics: bool, check_alignment: bool, ) -> Self { </ins> CompileTimeInterpreter { steps_remaining: const_eval_limit.0, stack: Vec::new(), can_access_statics, <ins> check_alignment, </ins> } } }

#[inline(always)] fn enforce_alignment(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool { <del> ecx.tcx.sess.opts.unstable_opts.extra_const_ub_checks </del> <ins> ecx.machine.check_alignment </ins> } #[inline(always)]

let strict = tcx.sess.opts.unstable_opts.strict_init_checks; if strict { <del> let machine = CompileTimeInterpreter::new(Limit::new(0), false); </del> <ins> let machine = CompileTimeInterpreter::new( Limit::new(0), /*can_access_statics:*/ false, /*check_alignment:*/ true, ); </ins> let mut cx = InterpCx::new(tcx, rustc_span::DUMMY_SP, ParamEnv::reveal_all(), machine);

<ins> // check-pass // compile-flags: -Zextra-const-ub-checks #[derive(PartialEq, Eq, Copy, Clone)] #[repr(packed)] struct Foo { field: (i64, u32, u32, u32), } const FOO: Foo = Foo { field: (5, 6, 7, 8), }; fn main() { match FOO { Foo { field: (5, 6, 7, 8) } => {}, FOO => unreachable!(), _ => unreachable!(), } } </ins>