Rust-GCC / Rust-GCC/gccrs

ICE `in query_compile, at rust/backend/rust-compile-resolve-path.cc` array size via method ?

Open
#3,936 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
2.9k
Forks
230
Avg merge
19h 55m
Merged PRs (30d)
67

Description

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
trait Dim {
    fn dim() -> usize;
}

enum Dim3 {}

impl Dim for Dim3 {
    fn main() {
        let array: [usize; Dim3::dim()] = [0; Dim3::dim()];
    }
}

original:

trait Dim {
    fn dim() -> usize;
}

enum Dim3 {}

impl Dim for Dim3 {
    fn main() {
    let array: [usize; Dim3::dim()]
    //~^ ERROR E0015
    //~| ERROR E0080
        = [0; Dim3::dim()];
        //~^ ERROR E0015
        //~| ERROR E0080
}
}

fn main() {
    let array: [usize; Dim3::dim()]
    //~^ ERROR E0015
    //~| ERROR E0080
        = [0; Dim3::dim()];
        //~^ ERROR E0015
        //~| ERROR E0080
}

Version information:

5c3e2adc695b04a199d37cacd8c23b14fdab914f

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5c3e2adc695b04a199d37cacd8c23b14fdab914f/gcc/rust/backend/rust-compile-resolve-path.cc#L338-L350

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

crab1: internal compiler error: in query_compile, at rust/backend/rust-compile-resolve-path.cc:344
0x2fec938 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0xc0dfbb fancy_abort(char const*, int, char const*)
	../../gcc/diagnostic.cc:1803
0x8fcfbf 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:344
0xdcf163 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
0xdcf329 Rust::Compile::ResolvePathRef::resolve(Rust::HIR::PathIdentSegment const&, Rust::Analysis::NodeMapping const&, unsigned long, bool)
	../../gcc/rust/backend/rust-compile-resolve-path.cc:232
0xdcf5eb tree_node* Rust::Compile::ResolvePathRef::resolve_path_like<Rust::HIR::PathInExpression>(Rust::HIR::PathInExpression&)
	../../gcc/rust/backend/rust-compile-resolve-path.cc:68
0xdcf5eb Rust::Compile::ResolvePathRef::Compile(Rust::HIR::PathInExpression&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-resolve-path.cc:46
0x115e1cf ???
	../../gcc/rust/backend/rust-compile-expr.h:59
0x1167fcd Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:48
0x1167fcd Rust::Compile::CompileExpr::visit(Rust::HIR::CallExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:1322
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
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reduced Rust reproducer and the query_compile path in gcc/rust/backend/rust-compile-resolve-path.cc around lines 338-350. Run crab1 with -frust-incomplete-and-experimental-compiler-do-not-use and inspect the const-expression path shown in the backtrace. Done means this input reports the applicable Rust errors without triggering an 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.