Skip to content

ICE when using size_of in rust-lang/stdarch tests on i686-pc-windows-msvc #148104

@folkertdev

Description

@folkertdev

Code

We hit the following in a stdarch CI job for i686-pc-windows-msvc. Other targets appear to be unaffected.

https://triage.rust-lang.org/gha-logs/rust-lang/stdarch/53655080976?pr=1944

The location is in this definition:

#[target_feature(enable = "sse2")]
unsafe fn load_m128i_word<T>(data: &[T], word_index: usize) -> __m128i {
    let byte_offset = word_index * 16 / size_of::<T>();
    let pointer = data.as_ptr().add(byte_offset) as *const __m128i;
    _mm_loadu_si128(black_box(pointer))
}

I cannot actually reproduce this locally though (I'm on linux, so cannot actually link for this target). Also godbolt still uses a slightly older nightly, the problem does not show up there. Regardless the minimal example should be https://godbolt.org/z/Eanszsdb5.

rust-lang/stdarch#1945 mitigates the issue by using byte_add so the size_of::<T> is no longer needed. We can work around this issue, but it still seems odd.

Meta

rustc --version --verbose:

nightly-x86_64-pc-windows-msvc unchanged - rustc 1.92.0-nightly (2aaa62b89 2025-10-24)

I can't run the command exactly. But the code fails with a recent nightly. The function that errors has not been touched in a while, so this is probably a compiler issue somehow.

Error output

error: internal compiler error: /rustc-dev/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce\compiler\rustc_codegen_ssa\src\mir\intrinsic.rs:123:21: nullary intrinsic size_of must either be in a const block or explicitly opted out because it is inherently a runtime intrinsic
   --> crates\core_arch\src\x86\gfni.rs:886:45
    |
886 |         let byte_offset = word_index * 16 / size_of::<T>();
    |                                             ^^^^^^^^^^^^^^
Backtrace

stack backtrace:
   0:     0x7ffcb6953a22 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ffcb6953a22 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffcb6953a22 - std::sys::backtrace::_print_fmt
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\sys\backtrace.rs:66
   3:     0x7ffcb6953a22 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\sys\backtrace.rs:39
   4:     0x7ffcb696912a - core::fmt::rt::Argument::fmt
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\core\src\fmt\rt.rs:173
   5:     0x7ffcb696912a - core::fmt::write
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\core\src\fmt\mod.rs:1469
   6:     0x7ffcb691ad47 - std::io::default_write_fmt
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\io\mod.rs:639
   7:     0x7ffcb691ad47 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\io\mod.rs:1954
   8:     0x7ffcb69336c5 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\sys\backtrace.rs:42
   9:     0x7ffcb693b079 - std::panicking::default_hook::closure$0
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\panicking.rs:301
  10:     0x7ffcb693ae68 - std::panicking::default_hook
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\panicking.rs:328
  11:     0x7ffcb813e074 - core[b98089486264e17e]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[e3689d7f24339034]::Level, &str), usize), <((rustc_lint_defs[e3689d7f24339034]::Level, &str), usize) as core[b98089486264e17e]::cmp::PartialOrd>::lt>
  12:     0x7ffcb693b93a - std::panicking::panic_with_hook
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\panicking.rs:842
  13:     0x7ffcba7ffea3 - RINvNtNtNtNtCsfVqf9Geh42o_4core5slice4sort6stable9quicksort9quicksortTjRNtNtCsdbijmOdzUpw_12rustc_errors7snippet10AnnotationENCINvMNtCscy1wuF44rYE_5alloc5sliceSB15_11sort_by_keyTINtNtBa_3cmp7ReversejEbENCNCNvMs4_NtB1c_7emitterNtB3o_12HumanEmitter18render_s
  14:     0x7ffcba7f3d59 - std[fdcb0a6535607765]::sys::backtrace::__rust_end_short_backtrace::<std[fdcb0a6535607765]::panicking::begin_panic<rustc_errors[998a81b21785ad88]::ExplicitBug>::{closure#0}, !>
  15:     0x7ffcba7f3a18 - std[fdcb0a6535607765]::panicking::begin_panic::<rustc_errors[998a81b21785ad88]::ExplicitBug>
  16:     0x7ffcba80dd25 - <rustc_errors[998a81b21785ad88]::diagnostic::BugAbort as rustc_errors[998a81b21785ad88]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x7ffcba69cfbf - RINvMs6_NtCskhOX23LNGmh_9hashbrown3rawINtB6_8RawTablejE14reserve_rehashNCINvNtNtCskn0Ger2eFdV_8indexmap3map4core8get_hashTNtNtCsajN8g4cgE90_9rustc_hir3def9NamespaceNtNtCsgtMjEw7bnrM_10rustc_span6symbol6SymbolEINtNtCsfVqf9Geh42o_4core6option6OptionNtNtB2G_6
  18:     0x7ffcba6c5ba6 - <rustc_data_structures[e923fc13fbe84b36]::profiling::SelfProfilerRef>::exec::cold_call::<<rustc_data_structures[e923fc13fbe84b36]::profiling::SelfProfilerRef>::incr_result_hashing::{closure#0}>
  19:     0x7ffcba6c5ded - <rustc_data_structures[e923fc13fbe84b36]::profiling::SelfProfilerRef>::exec::cold_call::<<rustc_data_structures[e923fc13fbe84b36]::profiling::SelfProfilerRef>::incr_result_hashing::{closure#0}>
  20:     0x7ffcba6b58c6 - core[b98089486264e17e]::slice::sort::unstable::ipnsort::<(<rustc_middle[f6dd1b8378577f3a]::mir::mono::CodegenUnit>::items_in_deterministic_order::ItemSortKey, usize), <(<rustc_middle[f6dd1b8378577f3a]::mir::mono::CodegenUnit>::items_in_deterministic_order::ItemSortKey, usize) as core[b98089486264e17e]::cmp::PartialOrd>::lt>
  21:     0x7ffcba6b3f19 - rustc_middle[f6dd1b8378577f3a]::util::bug::span_bug_fmt::<rustc_span[bff4d55158526bb0]::span_encoding::Span>
  22:     0x7ffcb3f772ff - RINvNtNtNtNtCsfVqf9Geh42o_4core5slice4sort6stable9quicksort9quicksortTNtNtCscy1wuF44rYE_5alloc6string6StringB16_ENCINvMNtB1a_5sliceSB15_7sort_byNCINvXs1g_NtNtNtB1a_11collections5btree3mapINtB2s_8BTreeMapB16_B16_EINtNtNtNtBa_4iter6traits7collect12FromIterat
  23:     0x7ffcb6a38794 - <alloc[9229d7763bf6039e]::raw_vec::RawVec<rustc_middle[f6dd1b8378577f3a]::ty::generic_args::GenericArg>>::grow_one
  24:     0x7ffcb69e4ce8 - <hashbrown[8b98e98ecbed7280]::raw::RawTable<((&rustc_codegen_llvm[357ea2b0bcfec854]::llvm::ffi::Metadata, usize), &rustc_codegen_llvm[357ea2b0bcfec854]::llvm::ffi::Metadata)>>::reserve_rehash::<hashbrown[8b98e98ecbed7280]::map::make_hasher<(&rustc_codegen_llvm[357ea2b0bcfec854]::llvm::ffi::Metadata, usize), &rustc_codegen_llvm[357ea2b0bcfec854]::llvm::ffi::Metadata, rustc_hash[686f3a0f6317ec19]::FxBuildHasher>::{closure#0}>
  25:     0x7ffcb6a6f8f6 - <alloc[9229d7763bf6039e]::raw_vec::RawVec<rustc_middle[f6dd1b8378577f3a]::ty::generic_args::GenericArg>>::grow_one
  26:     0x7ffcb3fb3b62 - <rustc_codegen_llvm[357ea2b0bcfec854]::LlvmCodegenBackend as rustc_codegen_ssa[2dd9de867fa07561]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  27:     0x7ffcb3f537b8 - rustc_interface[cfc686cb91dae03b]::interface::parse_cfg
  28:     0x7ffcb3fbada3 - <rustc_codegen_llvm[357ea2b0bcfec854]::LlvmCodegenBackend as rustc_codegen_ssa[2dd9de867fa07561]::traits::backend::CodegenBackend>::codegen_crate
  29:     0x7ffcb3f20c38 - <rustc_interface[cfc686cb91dae03b]::queries::Linker>::codegen_and_build_linker
  30:     0x7ffcb3ec9c5f - std[fdcb0a6535607765]::sys::backtrace::__rust_begin_short_backtrace::<<std[fdcb0a6535607765]::thread::Builder>::spawn_unchecked_<ctrlc[60f1abb1ac11c8e9]::set_handler_inner<rustc_driver_impl[fdad9a0dfcd1ba21]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  31:     0x7ffcb3ec27df - RINvNtNtCslMVXBJ6PtkL_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCshPZ0O03mfVL_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCslMk0CRZ32z5_17rustc_driver_i
  32:     0x7ffcb3ed087d - std[fdcb0a6535607765]::sys::backtrace::__rust_begin_short_backtrace::<<std[fdcb0a6535607765]::thread::Builder>::spawn_unchecked_<ctrlc[60f1abb1ac11c8e9]::set_handler_inner<rustc_driver_impl[fdad9a0dfcd1ba21]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  33:     0x7ffcb692bbbd - alloc::boxed::impl$29::call_once
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\alloc\src\boxed.rs:2005
  34:     0x7ffcb692bbbd - alloc::boxed::impl$29::call_once
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\alloc\src\boxed.rs:2005
  35:     0x7ffcb692bbbd - std::sys::thread::windows::impl$0::new::thread_start
                               at /rustc/2aaa62b89d22b570e560731b03e3d2d6f5c3bbce/library\std\src\sys\thread\windows.rs:60
  36:     0x7ffd023ce8d7 - BaseThreadInitThunk
  37:     0x7ffd0464c53c - RtlUserThreadStart

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions