Rust-GCC / Rust-GCC/gccrs

ICE in visit, at rust/backend/rust-compile-expr.cc:1417

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

Nobody has claimed this yet.

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

Description

Code
struct A<const N: &'static str>
{
    value: [usize; N.len()],
}
impl<const N: &'static str> A<N>
{
    fn func() -> Self {
        Self {
            value: [0; N.len()],
        }
    }
}

Version information
5c3e2ad
Command
gccrs -frust-incomplete-and-experimental-compiler-do-not-use ./test.rs
Program output
./test.rs:3:22: error: no method named ‘len’ found in the current scope [E0599]
    3 |     value: [usize; N.len()],
      |                      ^~~
      |                      method not found
./test.rs:9:26: error: no method named ‘len’ found in the current scope [E0599]
    9 |             value: [0; N.len()],
      |                          ^~~
      |                          method not found
./test.rs:9:20: error: mismatched types, expected ‘usize’ but got ‘<tyty::error>’ [E0308]
    9 |             value: [0; N.len()],
      |                    ^   ~
crab1: internal compiler error: in visit, at rust/backend/rust-compile-expr.cc:1417
0x29abeb6 internal_error(char const*, ...)
        ../../gccrs/gcc/diagnostic-global-context.cc:517
0xb48036 fancy_abort(char const*, int, char const*)
        ../../gccrs/gcc/diagnostic.cc:1803
0x91c0a9 Rust::Compile::CompileExpr::visit(Rust::HIR::MethodCallExpr&)
        ../../gccrs/gcc/rust/backend/rust-compile-expr.cc:1417
0xf883d4 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
        ../../gccrs/gcc/rust/backend/rust-compile-expr.cc:48
0xfaccd4 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)
        ../../gccrs/gcc/rust/backend/rust-compile-base.cc:869
0xfad150 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)
        ../../gccrs/gcc/rust/backend/rust-compile-base.cc:573
0xfad150 Rust::Compile::HIRCompileBase::query_compile_const_expr(Rust::Compile::Context*, Rust::TyTy::BaseType*, Rust::HIR::Expr&)
        ../../gccrs/gcc/rust/backend/rust-compile-base.cc:588
0xef9e58 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::ArrayExpr&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:1111
0xef1543 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0xee9488 Rust::Resolver::TypeCheckStructExpr::visit(Rust::HIR::StructExprFieldIdentifierValue&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-struct.cc:288
0xeea97b Rust::Resolver::TypeCheckStructExpr::resolve(Rust::HIR::StructExprStructFields&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-struct.cc:120
0xeebb6a Rust::Resolver::TypeCheckStructExpr::Resolve(Rust::HIR::StructExprStructFields&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-struct.cc:38
0xef0aff ???
        /usr/include/c++/11/bits/stl_tree.h:1878
0xef1543 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0xef27e5 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:627
0xef1543 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0xf04b36 Rust::Resolver::TypeCheckImplItem::visit(Rust::HIR::Function&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-implitem.cc:380
0xf053a5 Rust::Resolver::TypeCheckImplItem::Resolve(Rust::HIR::ImplBlock&, Rust::HIR::ImplItem&, Rust::TyTy::BaseType*, std::vector<Rust::TyTy::SubstitutionParamMapping, std::allocator<Rust::TyTy::SubstitutionParamMapping> >)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-implitem.cc:194
0xedf6e8 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::ImplBlock&)
        ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:534
0xed6990 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
        ../../gccrs/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

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 by reproducing the ICE with test.rs using gccrs -frust-incomplete-and-experimental-compiler-do-not-use, then inspect Rust::Compile::CompileExpr::visit in rust/backend/rust-compile-expr.cc around line 1417. Trace how the reported method-resolution errors reach that visitor. Done means the example produces diagnostics 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
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.