Rust-GCC / Rust-GCC/gccrs

ICE in get_field_at_index, at rust/typecheck/rust-tyty.cc:1487

Open
#3,542 1 comment 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

auto-reduced (treereduce-rust):

fn main() {
    enum R {
        REB(()),
    }
    struct Tau {
        t: usize,
    }
    enum E {
        B(R, Tau),
    }

    let e = E::B(R::REB(()), Tau { t: 3 });
}

original:

// Regression test for #15896. It used to ICE rustc.

fn main() {
    enum R { REB(()) }
    struct Tau { t: usize }
    enum E { B(R, Tau) }

    let e = E::B(R::REB(()), Tau { t: 3 });
    let u = match e {
        E::regular_fn(
          Tau{t: x},
          //~^ ERROR mismatched types
          _) => x,
    };
}

Version information:

a988708b4ba2b5a27715ea34c09ccfd3ed5143ca

Command:
crab1 -Warray-bounds -mtune=generic -march=x86-64 -O0 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

crab1: internal compiler error: in get_field_at_index, at rust/typecheck/rust-tyty.cc:1487
0x86977c Rust::TyTy::VariantDef::get_field_at_index(unsigned long)
	../../gcc/rust/typecheck/rust-tyty.cc:1487
0x86977c Rust::TyTy::VariantDef::get_field_at_index(unsigned long)
	../../gcc/rust/typecheck/rust-tyty.cc:1485
0xeb34c7 Rust::TyTy::TypeCheckCallExpr::visit(Rust::TyTy::ADTType&)
	../../gcc/rust/typecheck/rust-tyty-call.cc:79
0xeb34c7 Rust::TyTy::TypeCheckCallExpr::visit(Rust::TyTy::ADTType&)
	../../gcc/rust/typecheck/rust-tyty-call.cc:56
0xf22d8a Rust::TyTy::TypeCheckCallExpr::go(Rust::TyTy::BaseType*, Rust::HIR::CallExpr&, Rust::TyTy::VariantDef&, Rust::Resolver::TypeCheckContext*)
	../../gcc/rust/typecheck/rust-tyty-call.h:39
0xf22d8a Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::CallExpr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:219
0xf192b8 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:47
0xf28e21 Rust::Resolver::TypeCheckStmt::visit(Rust::HIR::LetStmt&)
	../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:84
0xf28f15 Rust::Resolver::TypeCheckStmt::Resolve(Rust::HIR::Stmt&)
	../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:34
0xf1aaa1 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:602
0xf192b8 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:47
0xef6140 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::Function&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:638
0xeecb37 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:59
0xe84e8b Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
	../../gcc/rust/typecheck/rust-hir-type-check.cc:75
0xc5c2d3 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

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 ICE at rust/typecheck/rust-tyty.cc:1487. Read the call path through rust-tyty-call.cc:79 and run the reported compiler command against the reproducer. Done means this input no longer triggers an internal compiler error and reports the expected type error shown in the original case.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.