Description
Given the following code:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0a24628f94a07753519f86993f792ddb
#[cfg(target_arch = "x86_64")]
fn main() {
use std::arch::x86_64::*;
unsafe {
let a: __m128 = _mm_setzero_ps();
let b: __m128 = _mm_setzero_ps();
let _blended = _mm_blend_ps(a, b, 0x33);
}
}
The current output is:
error[E0080]: evaluation of constant value failed
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/macros.rs:8:17
|
8 | let _ = 1 / ((IMM >= MIN && IMM <= MAX) as usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to divide `1_usize` by zero
error: internal compiler error: src/tools/miri/src/diagnostics.rs:94:21: This error should be impossible in Miri: encountered constants with type errors, stopping evaluation
Pointing to these lines inside std::arch
:
https://github.com/rust-lang/stdarch/blob/master/crates/core_arch/src/macros.rs#L5-L10
The error message only points to the final site where const evaluation failed in std::arch
. Ideally the error would point higher to the calling code that caused the const evaluation. If this error occurs deep within the dependency graph of a project, there's no easy way to deduce which crate is making the problematic call and causing the build to fail. I resorted to grepping .cargo for arch::
and lots of trial and error. Neither --verbose
nor RUST_BACKTRACE
were helpful. Someone later mentioned that RUSTC_LOG=rustc_mir::interpret=info
could help track it down, but this is user-unfriendly.
Impacting this issue in the wild:
ejmahler/RustFFT#74
rust-lang/stdarch#1159
1.54.0-nightly
(2021-05-09 ca82264ec7556a6011b9)