ICE: ` tree check: expected none of record_type or union_type or qual_union_type or array_type, have record_type in fold_binary_loc`
Open
Nobody has claimed this yet.
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
fn foo() {
let _ = [0u64; {} + 1];
}
original:
fn foo<const N: usize>() {
let _ = [0u64; {
let _ = [0u64; N + 1];
} + 1];
}
fn main() {}
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.n4soCVqUjDHu/rustc_testrunner_tmpdir_reporting.WBnrh9dCHsW4/mvce.rs:2:20: error: cannot apply operator ‘+’ to types () and <integer>
2 | let _ = [0u64; {} + 1];
| ^
/tmp/icemaker_global_tempdir.n4soCVqUjDHu/rustc_testrunner_tmpdir_reporting.WBnrh9dCHsW4/mvce.rs:2:13: error: mismatched types, expected ‘usize’ but got ‘<tyty::error>’ [E0308]
2 | let _ = [0u64; {} + 1];
| ^ ~
crab1: internal compiler error: tree check: expected none of record_type or union_type or qual_union_type or array_type, have record_type in fold_binary_loc, at fold-const.cc:11431
0x2fec938 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0xa7e629 tree_not_check_failed(tree_node const*, char const*, int, char const*, ...)
../../gcc/tree.cc:9139
0x95a9f9 tree_not_check4(tree_node*, char const*, int, char const*, tree_code, tree_code, tree_code, tree_code)
../../gcc/tree.h:3788
0x95a9f9 fold_binary_loc(unsigned long, tree_code, tree_node*, tree_node*, tree_node*)
../../gcc/fold-const.cc:11431
0x1453efe fold_build2_loc(unsigned long, tree_code, tree_node*, tree_node*, tree_node*)
../../gcc/fold-const.cc:13953
0xc87a6d Backend::arithmetic_or_logical_expression(ArithmeticOrLogicalOperator, tree_node*, tree_node*, unsigned long)
../../gcc/rust/rust-gcc.cc:1092
0xc87a6d Backend::arithmetic_or_logical_expression(ArithmeticOrLogicalOperator, tree_node*, tree_node*, unsigned long)
../../gcc/rust/rust-gcc.cc:1053
0x1166351 Rust::Compile::CompileExpr::visit(Rust::HIR::ArithmeticOrLogicalExpr&)
../../gcc/rust/backend/rust-compile-expr.cc:168
0x1162ab6 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
../../gcc/rust/backend/rust-compile-expr.cc:48
0x118e72f 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
0x118ee84 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
0x118ee84 Rust::Compile::HIRCompileBase::query_compile_const_expr(Rust::Compile::Context*, Rust::TyTy::BaseType*, Rust::HIR::Expr&)
../../gcc/rust/backend/rust-compile-base.cc:588
0x109f700 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::ArrayExpr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1111
0x109a314 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x10a9eb1 Rust::Resolver::TypeCheckStmt::visit(Rust::HIR::LetStmt&)
../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:90
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
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 reduced Rust case with the reported compiler command and inspect Backend::arithmetic_or_logical_expression in gcc/rust/rust-gcc.cc. Follow the constant-expression path through rust-compile-expr.cc, rust-compile-base.cc, and rust-hir-type-check-expr.cc. Done means the case emits diagnostics without triggering the internal compiler error.
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