[ICE]: BoundsCheckFailed in valtree_to_const_val
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
#![feature(min_generic_const_args)]
#![feature(macroless_const_item_generic_const_args)]
pub struct Data([u8; 3]);
const DATA: Data = Data([1, 2, 3, 4]);
fn main() {
match DATA {
_ => (),
}
}
original:
#![feature(min_generic_const_args)]
#![feature(macroless_const_item_generic_const_args)]
#![feature(min_adt_const_params)]
use std::marker::ConstParamTy;
#[derive(ConstParamTy, PartialEq, Eq)]
pub struct Data([u8; 3]);
const DATA: Data = Data([1, 2, 3, 4]);
fn main() {
match DATA {
_ => (),
}
}
Version information
rustc 1.100.0-nightly (50d54098e 2026-09-18)
binary: rustc
commit-hash: 50d54098ec9e61b3e2e72daa6368fd98e7f91e83
commit-date: 2026-09-18
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1
Possibly related line of code:
https://github.com/rust-lang/rust/blob/50d54098ec9e61b3e2e72daa6368fd98e7f91e83/compiler/rustc_const_eval/src/const_eval/valtrees.rs#L452-L464
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.WGaBg5bJvojo/rustc_testrunner_tmpdir_reporting.R5S4p942QiT6/mvce.rs:1:12
|
1 | #![feature(min_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `macroless_const_item_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.WGaBg5bJvojo/rustc_testrunner_tmpdir_reporting.R5S4p942QiT6/mvce.rs:2:12
|
2 | #![feature(macroless_const_item_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #162540 <https://github.com/rust-lang/rust/issues/162540> for more information
error[E0741]: `Data` must implement `ConstParamTy` to be used as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.WGaBg5bJvojo/rustc_testrunner_tmpdir_reporting.R5S4p942QiT6/mvce.rs:6:13
|
6 | const DATA: Data = Data([1, 2, 3, 4]);
| ^^^^
|
help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct
|
4 + #[derive(ConstParamTy, PartialEq, Eq)]
5 | pub struct Data([u8; 3]);
|
error: the constant `*b"\x01\x02\x03\x04"` is not of type `[u8; 3]`
--> /tmp/icemaker_global_tempdir.WGaBg5bJvojo/rustc_testrunner_tmpdir_reporting.R5S4p942QiT6/mvce.rs:6:1
|
6 | const DATA: Data = Data([1, 2, 3, 4]);
| ^^^^^^^^^^^^^^^^ expected `[u8; 3]`, found `[u8; 4]`
thread 'rustc' (3063716) panicked at /rustc-dev/50d54098ec9e61b3e2e72daa6368fd98e7f91e83/compiler/rustc_const_eval/src/const_eval/valtrees.rs:458:60:
called `Result::unwrap()` on an `Err` value: InterpErrorInfo(InterpErrorInfoInner { kind: UndefinedBehavior(BoundsCheckFailed { len: 3, index: 3 }), backtrace: InterpErrorBacktrace { backtrace: None } })
stack backtrace:
0: 0x7f406aa985f6 - <<std[701fe5a717b2ece3]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[fb54d2520af323a4]::fmt::Display>::fmt
1: 0x7f406b209955 - core[fb54d2520af323a4]::fmt::write
2: 0x7f406aaad5bc - <std[701fe5a717b2ece3]::sys::stdio::unix::Stderr as core[fb54d2520af323a4]::io::write::Write>::write_fmt
3: 0x7f406aa6b0fa - std[701fe5a717b2ece3]::panicking::default_hook::{closure#0}
4: 0x7f406aa8cba3 - std[701fe5a717b2ece3]::panicking::default_hook
5: 0x7f4069796062 - std[701fe5a717b2ece3]::panicking::update_hook::<alloc[4e1f854bc0e939aa]::boxed::Box<rustc_driver_impl[54d660f722e6d73c]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f406aa8d042 - std[701fe5a717b2ece3]::panicking::panic_with_hook
7: 0x7f406aa6b1b2 - std[701fe5a717b2ece3]::panicking::panic_handler::{closure#0}
8: 0x7f406aa63fc9 - std[701fe5a717b2ece3]::sys::backtrace::__rust_end_short_backtrace::<std[701fe5a717b2ece3]::panicking::panic_handler::{closure#0}, !>
9: 0x7f406aa6cd8d - __rustc[56fcff5126bc137a]::rust_begin_unwind
10: 0x7f406746328c - core[fb54d2520af323a4]::panicking::panic_fmt
11: 0x7f4066950602 - core[fb54d2520af323a4]::result::unwrap_failed
12: 0x7f406bb113d0 - rustc_const_eval[6631c4e7f6681619]::const_eval::valtrees::valtree_into_mplace
13: 0x7f406bb11287 - rustc_const_eval[6631c4e7f6681619]::const_eval::valtrees::valtree_into_mplace
14: 0x7f4068048ca1 - rustc_const_eval[6631c4e7f6681619]::const_eval::valtrees::valtree_to_const_value
15: 0x7f406c2f4a33 - <rustc_const_eval[6631c4e7f6681619]::provide::{closure#1} as core[fb54d2520af323a4]::ops::function::FnOnce<(rustc_middle[675e34273f79894d]::ty::context::TyCtxt, rustc_middle[675e34273f79894d]::ty::consts::valtree::Value)>>::call_once
16: 0x7f406c2f49ee - rustc_query_impl[72846e19b1bf9b7c]::query_vtables::valtree_to_const_val::invoke_provider_fn::__rust_begin_short_backtrace
17: 0x7f406c2f4281 - rustc_query_impl[72846e19b1bf9b7c]::execution::try_execute_query::<rustc_middle[675e34273f79894d]::query::caches::DefaultCache<rustc_middle[675e34273f79894d]::ty::consts::valtree::Value, rustc_middle[675e34273f79894d]::query::erase::ErasedData<[u8; 24usize]>>, false>
18: 0x7f406c2f3faa - rustc_query_impl[72846e19b1bf9b7c]::query_vtables::valtree_to_const_val::execute_query_non_incr::__rust_end_short_backtrace
19: 0x7f406bf19429 - <rustc_mir_transform[7d7261dfe82ceca2]::known_panics_lint::ConstPropagator as rustc_middle[675e34273f79894d]::mir::visit::Visitor>::visit_assign
20: 0x7f406bf11a26 - <rustc_mir_transform[7d7261dfe82ceca2]::known_panics_lint::ConstPropagator as rustc_middle[675e34273f79894d]::mir::visit::Visitor>::visit_body
21: 0x7f406bf0cfe9 - <rustc_mir_transform[7d7261dfe82ceca2]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[7d7261dfe82ceca2]::pass_manager::MirLint>::run_lint
22: 0x7f406b217e7e - rustc_mir_transform[7d7261dfe82ceca2]::run_analysis_to_runtime_passes
23: 0x7f406b74dd5d - rustc_mir_transform[7d7261dfe82ceca2]::mir_drops_elaborated_and_const_checked
24: 0x7f406b73977a - rustc_query_impl[72846e19b1bf9b7c]::execution::try_execute_query::<rustc_data_structures[3e77f9141b660bc6]::vec_cache::VecCache<rustc_span[5a3ffa2504eb3a6a]::def_id::LocalDefId, rustc_middle[675e34273f79894d]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[675e34273f79894d]::dep_graph::graph::DepNodeIndex>, false>
25: 0x7f406b7392a7 - rustc_query_impl[72846e19b1bf9b7c]::query_vtables::mir_drops_elaborated_and_const_checked::execute_query_non_incr::__rust_end_short_backtrace
26: 0x7f406b73c396 - <rustc_middle[675e34273f79894d]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[33ed3003e9db2d57]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
27: 0x7f406b73b4d4 - rustc_interface[33ed3003e9db2d57]::passes::analysis
28: 0x7f406c349507 - rustc_query_impl[72846e19b1bf9b7c]::execution::try_execute_query::<rustc_middle[675e34273f79894d]::query::caches::SingleCache<rustc_middle[675e34273f79894d]::query::erase::ErasedData<[u8; 0usize]>>, false>
29: 0x7f406c3492eb - rustc_query_impl[72846e19b1bf9b7c]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
30: 0x7f406c5d850f - rustc_interface[33ed3003e9db2d57]::interface::run_compiler::<(), rustc_driver_impl[54d660f722e6d73c]::run_compiler::{closure#0}>::{closure#2}
31: 0x7f406c5b90e4 - std[701fe5a717b2ece3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[33ed3003e9db2d57]::util::run_in_thread_with_globals<rustc_interface[33ed3003e9db2d57]::util::run_in_thread_pool_with_globals<rustc_interface[33ed3003e9db2d57]::interface::run_compiler<(), rustc_driver_impl[54d660f722e6d73c]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
32: 0x7f406c5b8e81 - <std[701fe5a717b2ece3]::thread::lifecycle::spawn_unchecked<rustc_interface[33ed3003e9db2d57]::util::run_in_thread_with_globals<rustc_interface[33ed3003e9db2d57]::util::run_in_thread_pool_with_globals<rustc_interface[33ed3003e9db2d57]::interface::run_compiler<(), rustc_driver_impl[54d660f722e6d73c]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[fb54d2520af323a4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
33: 0x7f406c5c441b - <std[701fe5a717b2ece3]::sys::thread::unix::Thread>::new::thread_start
34: 0x7f40652980a2 - <unknown>
35: 0x7f406532080c - <unknown>
36: 0x0 - <unknown>
error: the compiler unexpectedly panicked. This is a bug
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: rustc 1.100.0-nightly (50d54098e 2026-09-18) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [valtree_to_const_val] converting type-level constant value to MIR constant value
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0741`.
@rustbot label +F-min_generic_const_args +F-min_adt_const_params
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the reduced example with the listed nightly rustc command and inspect compiler/rustc_const_eval/src/const_eval/valtrees.rs around line 458. Trace valtree_to_const_val through the reported query stack and compare the BoundsCheckFailed with the existing diagnostics. Done means the reproducer no longer causes an internal compiler error and reports the invalid constant appropriately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100