ICE `expected integer_cst, have var_decl in to_wide`
Open
Nobody has claimed this yet.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
snippet:
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
fn main() {
let _: [u8; 0] = [1; {
match usize::MAX as *const u8 as usize {
n => n,
}
}];
}
Version information:
5c3e2adc695b04a199d37cacd8c23b14fdab914f
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
/tmp/icemaker_global_tempdir.YKZ35le9Xkh1/rustc_testrunner_tmpdir_reporting.1TQDlzTpTgQr/mvce.rs:3:22: error: failed to resolve path segment using an impl Probe
3 | match usize::MAX as *const u8 as usize {
| ^~~
crab1: error: the value of ‘RUSTTMP.1’ is not usable in a constant expression
crab1: error: the value of ‘RUSTTMP.1’ is not usable in a constant expression
crab1: internal compiler error: tree check: expected integer_cst, have var_decl in to_wide, at tree.h:6563
0x2fec938 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0xa7e17c tree_check_failed(tree_node const*, char const*, int, char const*, ...)
../../gcc/tree.cc:9102
0x902ec7 tree_check(tree_node const*, char const*, int, char const*, tree_code)
../../gcc/tree.h:3999
0x902ec7 wi::to_wide(tree_node const*)
../../gcc/tree.h:6563
0x902ec7 Rust::TyTy::ArrayType::as_string[abi:cxx11]() const
../../gcc/rust/typecheck/rust-tyty.cc:2494
0x102f9eb Rust::TyTy::ArrayType::get_name[abi:cxx11]() const
../../gcc/rust/typecheck/rust-tyty.h:1180
0x10191bb Rust::TyTy::BaseType::debug_str[abi:cxx11]() const
../../gcc/rust/typecheck/rust-tyty.cc:676
0x111a58d Rust::Resolver::coercion_site(unsigned int, Rust::TyTy::TyWithLocation, Rust::TyTy::TyWithLocation, unsigned long)
../../gcc/rust/typecheck/rust-type-util.cc:238
0x10a9e4c Rust::Resolver::TypeCheckStmt::visit(Rust::HIR::LetStmt&)
../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:109
0x10a9fa3 Rust::Resolver::TypeCheckStmt::Resolve(Rust::HIR::Stmt&)
../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:34
0x109bd31 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:609
0x109a314 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x1077370 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::Function&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:642
0x106e105 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:59
0x100ad4b Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
../../gcc/rust/typecheck/rust-hir-type-check.cc:74
0xdb9778 Rust::Session::compile_crate(char const*)
../../gcc/rust/rust-session-manager.cc:685
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
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
Reproduce the ICE with the Rust snippet in /tmp/im/a.rs using -frust-incomplete-and-experimental-compiler-do-not-use. Start at Rust::TyTy::ArrayType::as_string in gcc/rust/typecheck/rust-tyty.cc:2494 and follow the callers shown in the backtrace. Done means the reproducer no longer reaches the tree check expecting an integer_cst.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100