Const eval does alignment checks #61952
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
The const eval engine takes quite a few steps to ensure that it bails out of evaluation if any steps would cause unaligned reads. E.g.
will fail to compile with
The question is, do we need to be this restrictive during const eval. The checks are everywhere, so we may even see perf gains from removing them, but the main gain would be that we can remove the additional code that just exists to ensure we fiddle the right alignment through the pattern-matching-on-constants logic (
ConstValue::ByRef
'sAlign
field is unused for anything else).I think there's little use in keeping this restriction in const eval, since it only exists in miri because some hardware platforms actually do UB on unaligned reads, while other platforms are simply slower on unaligned reads.
cc @RalfJung
The text was updated successfully, but these errors were encountered: