ICE `in visit at rust/backend/rust-compile-item.cc:104`
Open
@philberty is already working on this.
Since Jul 31, 2025.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
auto-reduced (treereduce-rust):
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
enum Flopsy {
Bunny = 2,
}
const BAR: usize = Flopsy::Bunny as usize;
const BAR2: usize = BAR;
pub fn main() {
let BAR2 = [2; BAR2];
const BAR3: usize = BAR2;
let _v = [0; BAR3];
}
original:
//@ run-pass
enum Flopsy {
Bunny = 2
}
const BAR:usize = Flopsy::Bunny as usize;
const BAR2:usize = BAR;
pub fn main() {
let _v = [0; Flopsy::Bunny as usize];
let _v = [0; BAR];
let BAR2 = [2; BAR2];
const BAR3:usize = BAR2;
let _v = [0; BAR3];
}
Version information:
5dc8c4d20d62462ebce137c6e5146235ab9e9e2e
Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5dc8c4d20d62462ebce137c6e5146235ab9e9e2e/gcc/rust/backend/rust-compile-item.cc#L98-L110
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
/tmp/icemaker_global_tempdir.qZaqYWnR3FC8/rustc_testrunner_tmpdir_reporting.qvCU4lr3cyD6/mvce.rs:5:20: error: casting ‘Flopsy’ as ‘usize’ is invalid [E0606]
5 | const BAR: usize = Flopsy::Bunny as usize;
| ^~~~~~ ~~~~~
/tmp/icemaker_global_tempdir.qZaqYWnR3FC8/rustc_testrunner_tmpdir_reporting.qvCU4lr3cyD6/mvce.rs:10:25: error: cannot find value ‘BAR2’ in this scope [E0425]
10 | const BAR3: usize = BAR2;
| ^~~~
crab1: error: aggregate value used where an integer was expected
/tmp/icemaker_global_tempdir.qZaqYWnR3FC8/rustc_testrunner_tmpdir_reporting.qvCU4lr3cyD6/mvce.rs:11:14: error: mismatched types, expected ‘usize’ but got ‘<tyty::error>’ [E0308]
11 | let _v = [0; BAR3];
| ^ ~~~~
crab1: internal compiler error: in visit, at rust/backend/rust-compile-item.cc:104
0x2fecaf8 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0xc0e04d fancy_abort(char const*, int, char const*)
../../gcc/diagnostic.cc:1803
0x9099b1 Rust::Compile::CompileItem::visit(Rust::HIR::ConstantItem&)
../../gcc/rust/backend/rust-compile-item.cc:104
0xdce702 Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned long)
../../gcc/rust/backend/rust-compile-item.h:37
0xdce702 Rust::Compile::HIRCompileBase::query_compile(unsigned int, Rust::TyTy::BaseType*, Rust::HIR::PathIdentSegment const&, Rust::Analysis::NodeMapping const&, unsigned long, bool)
../../gcc/rust/backend/rust-compile-resolve-path.cc:248
0xdcf1e3 Rust::Compile::ResolvePathRef::resolve_with_node_id(Rust::HIR::PathIdentSegment const&, Rust::Analysis::NodeMapping const&, unsigned long, bool, unsigned int)
../../gcc/rust/backend/rust-compile-resolve-path.cc:200
0xdcf3a9 Rust::Compile::ResolvePathRef::resolve(Rust::HIR::PathIdentSegment const&, Rust::Analysis::NodeMapping const&, unsigned long, bool)
../../gcc/rust/backend/rust-compile-resolve-path.cc:232
0xdcf66b tree_node* Rust::Compile::ResolvePathRef::resolve_path_like<Rust::HIR::PathInExpression>(Rust::HIR::PathInExpression&)
../../gcc/rust/backend/rust-compile-resolve-path.cc:68
0xdcf66b Rust::Compile::ResolvePathRef::Compile(Rust::HIR::PathInExpression&, Rust::Compile::Context*)
../../gcc/rust/backend/rust-compile-resolve-path.cc:46
0x115e38f ???
../../gcc/rust/backend/rust-compile-expr.h:59
0x1162c76 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
../../gcc/rust/backend/rust-compile-expr.cc:48
0x118e8ef Rust::Compile::HIRCompileBase::compile_constant_item(unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
../../gcc/rust/backend/rust-compile-base.cc:869
0x118f044 Rust::Compile::HIRCompileBase::compile_constant_expr(Rust::Compile::Context*, unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
../../gcc/rust/backend/rust-compile-base.cc:573
0x118f044 Rust::Compile::HIRCompileBase::query_compile_const_expr(Rust::Compile::Context*, Rust::TyTy::BaseType*, Rust::HIR::Expr&)
../../gcc/rust/backend/rust-compile-base.cc:588
0x109f8c0 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::ArrayExpr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1111
0x109a4d4 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x10aa071 Rust::Resolver::TypeCheckStmt::visit(Rust::HIR::LetStmt&)
../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:90
0x10aa163 Rust::Resolver::TypeCheckStmt::Resolve(Rust::HIR::Stmt&)
../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:34
0x109bef1 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:609
0x109a4d4 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
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.
Assessment
This issue has not been assessed yet.