Open
Description
This example hits an ICE. The area around the error message provides some context
rust/compiler/rustc_middle/src/ty/sty.rs
Lines 1175 to 1185 in ed49386
So, this is sort of expected. Maybe there is a more complete way of getting that length 5 years later?
Context: I'm trying to use this in the stdarch implementation of s390x vector intrinsics. The test
function below is actually in a macro, hence the calculation of N
that might look a bit weird at first glance.
Code
#![feature(portable_simd, repr_simd, core_intrinsics)]
#[derive(Debug, Clone, Copy)]
#[repr(simd)]
struct vector_signed_int([i32; 4]);
#[no_mangle]
unsafe fn test(a: vector_signed_int) -> vector_signed_int {
const N: usize = core::mem::size_of::<vector_signed_int>() / core::mem::size_of::<i32>();
#[repr(simd)]
struct Helper([u32; N]);
const INDEX: Helper = const {
let mut index = [0; N];
let mut i = 0;
while i < N {
index[i] = (N - i - 1) as u32;
i += 1;
}
Helper(index)
};
core::intrinsics::simd::simd_shuffle(a, a, INDEX)
}
fn main() {}
Meta
rustc --version --verbose
:
rustc 1.86.0-nightly (ef148cd7e 2025-02-12)
binary: rustc
commit-hash: ef148cd7eb00a5a973130dc6473da71fd6c487ee
commit-date: 2025-02-12
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Error output
<none>
Backtrace
thread 'rustc' panicked at compiler/rustc_middle/src/ty/sty.rs:1182:18:
expected SIMD field to have definite array size
stack backtrace:
0: 0x7bd140b7bc65 - std::backtrace::Backtrace::create::hbb6ec95241d4d0ca
1: 0x7bd13f03c875 - std::backtrace::Backtrace::force_capture::h28bcc72d9be8b631
2: 0x7bd13e1b45b4 - std[633b0bd6f2fb4ba3]::panicking::update_hook::<alloc[6f8679578b5d1085]::boxed::Box<rustc_driver_impl[da41d138b3cf9bec]::install_ice_hook::{closure#1}>>::{closure#0}
3: 0x7bd13f054ff3 - std::panicking::rust_panic_with_hook::h8a1db2c7a950f63a
4: 0x7bd13f054cea - std::panicking::begin_panic_handler::{{closure}}::hd4ae0500663b7b24
5: 0x7bd13f052679 - std::sys::backtrace::__rust_end_short_backtrace::h830be9a18b3fa6b1
6: 0x7bd13f0549ad - rust_begin_unwind
7: 0x7bd13bc415b0 - core::panicking::panic_fmt::h019406d7deaf35a5
8: 0x7bd13cdf17db - core::option::expect_failed::hca492385653fd117
9: 0x7bd14136fb19 - <rustc_middle[644c635b116d1ee0]::ty::Ty>::simd_size_and_type.cold
10: 0x7bd13fd71790 - <rustc_codegen_ssa[c9f50b7cd58b52ea]::mir::FunctionCx<rustc_codegen_llvm[58eb01b1dd183b6b]::builder::GenericBuilder<rustc_codegen_llvm[58eb01b1dd183b6b]::context::CodegenCx>>>::codegen_operand
11: 0x7bd14045574d - rustc_codegen_ssa[c9f50b7cd58b52ea]::mir::codegen_mir::<rustc_codegen_llvm[58eb01b1dd183b6b]::builder::GenericBuilder<rustc_codegen_llvm[58eb01b1dd183b6b]::context::CodegenCx>>
12: 0x7bd14042a0c8 - rustc_codegen_llvm[58eb01b1dd183b6b]::base::compile_codegen_unit::module_codegen
13: 0x7bd1406c7fae - <rustc_codegen_llvm[58eb01b1dd183b6b]::LlvmCodegenBackend as rustc_codegen_ssa[c9f50b7cd58b52ea]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
14: 0x7bd1406c3e97 - rustc_codegen_ssa[c9f50b7cd58b52ea]::base::codegen_crate::<rustc_codegen_llvm[58eb01b1dd183b6b]::LlvmCodegenBackend>
15: 0x7bd1406c322f - <rustc_codegen_llvm[58eb01b1dd183b6b]::LlvmCodegenBackend as rustc_codegen_ssa[c9f50b7cd58b52ea]::traits::backend::CodegenBackend>::codegen_crate
16: 0x7bd1408201f4 - <rustc_interface[4d9624c47f887345]::queries::Linker>::codegen_and_build_linker
17: 0x7bd1408181df - rustc_interface[4d9624c47f887345]::passes::create_and_enter_global_ctxt::<core[897dc7c96c0db261]::option::Option<rustc_interface[4d9624c47f887345]::queries::Linker>, rustc_driver_impl[da41d138b3cf9bec]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
18: 0x7bd140778e9c - rustc_interface[4d9624c47f887345]::interface::run_compiler::<(), rustc_driver_impl[da41d138b3cf9bec]::run_compiler::{closure#0}>::{closure#1}
19: 0x7bd1406ea404 - std[633b0bd6f2fb4ba3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4d9624c47f887345]::util::run_in_thread_with_globals<rustc_interface[4d9624c47f887345]::util::run_in_thread_pool_with_globals<rustc_interface[4d9624c47f887345]::interface::run_compiler<(), rustc_driver_impl[da41d138b3cf9bec]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
20: 0x7bd1406ea0d9 - <<std[633b0bd6f2fb4ba3]::thread::Builder>::spawn_unchecked_<rustc_interface[4d9624c47f887345]::util::run_in_thread_with_globals<rustc_interface[4d9624c47f887345]::util::run_in_thread_pool_with_globals<rustc_interface[4d9624c47f887345]::interface::run_compiler<(), rustc_driver_impl[da41d138b3cf9bec]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[897dc7c96c0db261]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
21: 0x7bd1406e986f - std::sys::pal::unix::thread::Thread::new::thread_start::h9cc83cf24679d9ac
22: 0x7bd13a69ca94 - start_thread
at ./nptl/pthread_create.c:447:8
23: 0x7bd13a729c3c - clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
24: 0x0 - <unknown>
rustc version: 1.86.0-nightly (ef148cd7e 2025-02-12)
platform: x86_64-unknown-linux-gnu
query stack during panic:
end of query stack
Metadata
Metadata
Assignees
Labels
Area: SIMD (Single Instruction Multiple Data)Area: Constant evaluation, covers all const contexts (static, const fn, ...)Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.Working group: Const evaluation