ICE: `expected record_type or union_type or qual_union_type, have integer_type in constructor_expression`
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 main() {
let e = [0; "foo"];
}
original:
fn main() {
let e = [0; "foo"];
}
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.472s4fwCTIcs/rustc_testrunner_tmpdir_reporting.qBTgC4NjIUWP/mvce.rs:2:13: error: mismatched types, expected ‘usize’ but got ‘& str’ [E0308]
2 | let e = [0; "foo"];
| ^ ~
crab1: internal compiler error: tree check: expected record_type or union_type or qual_union_type, have integer_type in constructor_expression, at rust/rust-gcc.cc:1259
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
0x8f987d tree_check3(tree_node*, char const*, int, char const*, tree_code, tree_code, tree_code)
../../gcc/tree.h:3751
0x8f987d Backend::constructor_expression(tree_node*, bool, std::vector<tree_node*, std::allocator<tree_node*> > const&, int, unsigned long)
../../gcc/rust/rust-gcc.cc:1259
0x1163d4e Rust::Compile::CompileExpr::compile_string_literal(Rust::HIR::LiteralExpr const&, Rust::TyTy::BaseType const*)
../../gcc/rust/backend/rust-compile-expr.cc:1766
0x1164384 ???
../../gcc/rust/backend/rust-compile-expr.h:38
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
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
Start with the reduced Rust input and inspect the ICE path at gcc/rust/rust-gcc.cc:1259, with the string-literal entry point in gcc/rust/backend/rust-compile-expr.cc:1766. Run the example with the reported compiler flag and confirm that the mismatched-type diagnostic is emitted without an internal compiler error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100